@epicgames-ps/lib-pixelstreamingfrontend-ue5.5 0.3.0 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commonjs/AFK/AFKController.js +109 -109
- package/dist/commonjs/Config/Config.js +559 -559
- package/dist/commonjs/Config/SettingBase.js +98 -98
- package/dist/commonjs/Config/SettingFlag.js +49 -49
- package/dist/commonjs/Config/SettingNumber.js +83 -83
- package/dist/commonjs/Config/SettingOption.js +84 -84
- package/dist/commonjs/Config/SettingText.js +42 -42
- package/dist/commonjs/DataChannel/DataChannelController.js +106 -106
- package/dist/commonjs/DataChannel/DataChannelLatencyTestController.js +94 -94
- package/dist/commonjs/DataChannel/DataChannelLatencyTestResults.js +18 -18
- package/dist/commonjs/DataChannel/DataChannelSender.js +43 -43
- package/dist/commonjs/DataChannel/InitialSettings.js +41 -41
- package/dist/commonjs/DataChannel/LatencyTestResults.js +60 -60
- package/dist/commonjs/FreezeFrame/FreezeFrame.js +93 -93
- package/dist/commonjs/FreezeFrame/FreezeFrameController.js +95 -95
- package/dist/commonjs/Inputs/GamepadController.js +188 -188
- package/dist/commonjs/Inputs/GamepadTypes.js +21 -21
- package/dist/commonjs/Inputs/IInputController.js +2 -2
- package/dist/commonjs/Inputs/InputClassesFactory.js +96 -96
- package/dist/commonjs/Inputs/KeyCodes.js +112 -112
- package/dist/commonjs/Inputs/KeyboardController.js +137 -137
- package/dist/commonjs/Inputs/MouseButtons.js +28 -28
- package/dist/commonjs/Inputs/MouseController.js +97 -97
- package/dist/commonjs/Inputs/MouseControllerHovering.js +93 -93
- package/dist/commonjs/Inputs/MouseControllerLocked.js +153 -153
- package/dist/commonjs/Inputs/SpecialKeyCodes.js +19 -19
- package/dist/commonjs/Inputs/TouchController.js +123 -123
- package/dist/commonjs/Inputs/TouchController.js.map +1 -1
- package/dist/commonjs/Inputs/TouchControllerFake.js +91 -91
- package/dist/commonjs/Inputs/XRGamepadController.js +124 -124
- package/dist/commonjs/PeerConnectionController/AggregatedStats.js +252 -252
- package/dist/commonjs/PeerConnectionController/CandidatePairStats.js +10 -10
- package/dist/commonjs/PeerConnectionController/CandidateStat.js +10 -10
- package/dist/commonjs/PeerConnectionController/CodecStats.js +10 -10
- package/dist/commonjs/PeerConnectionController/DataChannelStats.js +10 -10
- package/dist/commonjs/PeerConnectionController/InboundRTPStats.js +22 -22
- package/dist/commonjs/PeerConnectionController/InboundTrackStats.js +10 -10
- package/dist/commonjs/PeerConnectionController/OutBoundRTPStats.js +16 -16
- package/dist/commonjs/PeerConnectionController/PeerConnectionController.js +584 -584
- package/dist/commonjs/PeerConnectionController/SessionStats.js +10 -10
- package/dist/commonjs/PeerConnectionController/StreamStats.js +10 -10
- package/dist/commonjs/PixelStreaming/PixelStreaming.js +607 -607
- package/dist/commonjs/UI/OnScreenKeyboard.js +82 -82
- package/dist/commonjs/UeInstanceMessage/ResponseController.js +38 -38
- package/dist/commonjs/UeInstanceMessage/SendMessageController.js +120 -120
- package/dist/commonjs/UeInstanceMessage/StreamMessageController.js +210 -210
- package/dist/commonjs/UeInstanceMessage/ToStreamerMessagesController.js +49 -49
- package/dist/commonjs/Util/EventEmitter.js +386 -386
- package/dist/commonjs/Util/FileUtil.js +108 -108
- package/dist/commonjs/Util/IURLSearchParams.js +25 -25
- package/dist/commonjs/Util/InputCoordTranslator.js +49 -49
- package/dist/commonjs/Util/RTCUtils.js +40 -40
- package/dist/commonjs/VideoPlayer/StreamController.js +67 -67
- package/dist/commonjs/VideoPlayer/VideoPlayer.js +177 -177
- package/dist/commonjs/WebRtcPlayer/WebRtcPlayerController.js +1221 -1221
- package/dist/commonjs/WebXR/WebXRController.js +335 -335
- package/dist/commonjs/pixelstreamingfrontend.js +70 -70
- package/dist/esm/AFK/AFKController.js +105 -105
- package/dist/esm/Config/Config.js +551 -551
- package/dist/esm/Config/SettingBase.js +94 -94
- package/dist/esm/Config/SettingFlag.js +45 -45
- package/dist/esm/Config/SettingNumber.js +79 -79
- package/dist/esm/Config/SettingOption.js +80 -80
- package/dist/esm/Config/SettingText.js +38 -38
- package/dist/esm/DataChannel/DataChannelController.js +102 -102
- package/dist/esm/DataChannel/DataChannelLatencyTestController.js +90 -90
- package/dist/esm/DataChannel/DataChannelLatencyTestResults.js +14 -14
- package/dist/esm/DataChannel/DataChannelSender.js +39 -39
- package/dist/esm/DataChannel/InitialSettings.js +34 -34
- package/dist/esm/DataChannel/LatencyTestResults.js +56 -56
- package/dist/esm/FreezeFrame/FreezeFrame.js +89 -89
- package/dist/esm/FreezeFrame/FreezeFrameController.js +91 -91
- package/dist/esm/Inputs/GamepadController.js +184 -184
- package/dist/esm/Inputs/GamepadTypes.js +17 -17
- package/dist/esm/Inputs/IInputController.js +1 -1
- package/dist/esm/Inputs/InputClassesFactory.js +91 -91
- package/dist/esm/Inputs/KeyCodes.js +109 -109
- package/dist/esm/Inputs/KeyboardController.js +133 -133
- package/dist/esm/Inputs/MouseButtons.js +23 -23
- package/dist/esm/Inputs/MouseController.js +93 -93
- package/dist/esm/Inputs/MouseControllerHovering.js +89 -89
- package/dist/esm/Inputs/MouseControllerLocked.js +149 -149
- package/dist/esm/Inputs/SpecialKeyCodes.js +15 -15
- package/dist/esm/Inputs/TouchController.js +119 -119
- package/dist/esm/Inputs/TouchController.js.map +1 -1
- package/dist/esm/Inputs/TouchControllerFake.js +87 -87
- package/dist/esm/Inputs/XRGamepadController.js +120 -120
- package/dist/esm/PeerConnectionController/AggregatedStats.js +248 -248
- package/dist/esm/PeerConnectionController/CandidatePairStats.js +6 -6
- package/dist/esm/PeerConnectionController/CandidateStat.js +6 -6
- package/dist/esm/PeerConnectionController/CodecStats.js +6 -6
- package/dist/esm/PeerConnectionController/DataChannelStats.js +6 -6
- package/dist/esm/PeerConnectionController/InboundRTPStats.js +16 -16
- package/dist/esm/PeerConnectionController/InboundTrackStats.js +6 -6
- package/dist/esm/PeerConnectionController/OutBoundRTPStats.js +11 -11
- package/dist/esm/PeerConnectionController/PeerConnectionController.js +580 -580
- package/dist/esm/PeerConnectionController/SessionStats.js +6 -6
- package/dist/esm/PeerConnectionController/StreamStats.js +6 -6
- package/dist/esm/PixelStreaming/PixelStreaming.js +603 -603
- package/dist/esm/UI/OnScreenKeyboard.js +78 -78
- package/dist/esm/UeInstanceMessage/ResponseController.js +34 -34
- package/dist/esm/UeInstanceMessage/SendMessageController.js +116 -116
- package/dist/esm/UeInstanceMessage/StreamMessageController.js +205 -205
- package/dist/esm/UeInstanceMessage/ToStreamerMessagesController.js +45 -45
- package/dist/esm/Util/EventEmitter.js +345 -345
- package/dist/esm/Util/FileUtil.js +103 -103
- package/dist/esm/Util/IURLSearchParams.js +21 -21
- package/dist/esm/Util/InputCoordTranslator.js +45 -45
- package/dist/esm/Util/RTCUtils.js +36 -36
- package/dist/esm/VideoPlayer/StreamController.js +63 -63
- package/dist/esm/VideoPlayer/VideoPlayer.js +173 -173
- package/dist/esm/WebRtcPlayer/WebRtcPlayerController.js +1217 -1217
- package/dist/esm/WebXR/WebXRController.js +331 -331
- package/dist/esm/pixelstreamingfrontend.js +24 -24
- package/dist/types/AFK/AFKController.d.ts +38 -38
- package/dist/types/Config/Config.d.ts +220 -220
- package/dist/types/Config/SettingBase.d.ts +43 -43
- package/dist/types/Config/SettingFlag.d.ts +24 -24
- package/dist/types/Config/SettingNumber.d.ts +41 -41
- package/dist/types/Config/SettingOption.d.ts +41 -41
- package/dist/types/Config/SettingText.d.ts +21 -21
- package/dist/types/DataChannel/DataChannelController.d.ts +59 -59
- package/dist/types/DataChannel/DataChannelLatencyTestController.d.ts +25 -25
- package/dist/types/DataChannel/DataChannelLatencyTestResults.d.ts +46 -46
- package/dist/types/DataChannel/DataChannelSender.d.ts +21 -21
- package/dist/types/DataChannel/InitialSettings.d.ts +44 -44
- package/dist/types/DataChannel/LatencyTestResults.d.ts +31 -31
- package/dist/types/FreezeFrame/FreezeFrame.d.ts +36 -36
- package/dist/types/FreezeFrame/FreezeFrameController.d.ts +37 -37
- package/dist/types/Inputs/GamepadController.d.ts +61 -61
- package/dist/types/Inputs/GamepadTypes.d.ts +15 -15
- package/dist/types/Inputs/IInputController.d.ts +16 -16
- package/dist/types/Inputs/InputClassesFactory.d.ts +53 -53
- package/dist/types/Inputs/KeyCodes.d.ts +5 -5
- package/dist/types/Inputs/KeyboardController.d.ts +34 -34
- package/dist/types/Inputs/MouseButtons.d.ts +22 -22
- package/dist/types/Inputs/MouseController.d.ts +40 -40
- package/dist/types/Inputs/MouseControllerHovering.d.ts +26 -26
- package/dist/types/Inputs/MouseControllerLocked.d.ts +31 -31
- package/dist/types/Inputs/SpecialKeyCodes.d.ts +14 -14
- package/dist/types/Inputs/TouchController.d.ts +28 -28
- package/dist/types/Inputs/TouchControllerFake.d.ts +29 -29
- package/dist/types/Inputs/XRGamepadController.d.ts +15 -15
- package/dist/types/PeerConnectionController/AggregatedStats.d.ts +82 -82
- package/dist/types/PeerConnectionController/CandidatePairStats.d.ts +22 -22
- package/dist/types/PeerConnectionController/CandidateStat.d.ts +13 -13
- package/dist/types/PeerConnectionController/CodecStats.d.ts +14 -14
- package/dist/types/PeerConnectionController/DataChannelStats.d.ts +15 -15
- package/dist/types/PeerConnectionController/InboundRTPStats.d.ts +141 -141
- package/dist/types/PeerConnectionController/InboundTrackStats.d.ts +32 -32
- package/dist/types/PeerConnectionController/OutBoundRTPStats.d.ts +23 -23
- package/dist/types/PeerConnectionController/PeerConnectionController.d.ts +143 -143
- package/dist/types/PeerConnectionController/SessionStats.d.ts +8 -8
- package/dist/types/PeerConnectionController/StreamStats.d.ts +9 -9
- package/dist/types/PixelStreaming/PixelStreaming.d.ts +271 -271
- package/dist/types/UI/OnScreenKeyboard.d.ts +30 -30
- package/dist/types/UeInstanceMessage/ResponseController.d.ts +19 -19
- package/dist/types/UeInstanceMessage/SendMessageController.d.ts +18 -18
- package/dist/types/UeInstanceMessage/StreamMessageController.d.ts +29 -29
- package/dist/types/UeInstanceMessage/ToStreamerMessagesController.d.ts +32 -32
- package/dist/types/Util/EventEmitter.d.ts +429 -429
- package/dist/types/Util/FileUtil.d.ts +32 -32
- package/dist/types/Util/IURLSearchParams.d.ts +9 -9
- package/dist/types/Util/InputCoordTranslator.d.ts +29 -29
- package/dist/types/Util/RTCUtils.d.ts +8 -8
- package/dist/types/VideoPlayer/StreamController.d.ts +22 -22
- package/dist/types/VideoPlayer/VideoPlayer.d.ts +78 -78
- package/dist/types/WebRtcPlayer/WebRtcPlayerController.d.ts +379 -379
- package/dist/types/WebXR/WebXRController.d.ts +42 -42
- package/dist/types/pixelstreamingfrontend.d.ts +23 -23
- package/package.json +45 -45
- package/src/Inputs/TouchController.ts +3 -3
|
@@ -1,560 +1,560 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.ControlSchemeType = exports.Config = exports.OptionParameters = exports.TextParameters = exports.NumericParameters = exports.Flags = void 0;
|
|
5
|
-
const lib_pixelstreamingcommon_ue5_5_1 = require("@epicgames-ps/lib-pixelstreamingcommon-ue5.5");
|
|
6
|
-
const SettingFlag_1 = require("./SettingFlag");
|
|
7
|
-
const SettingNumber_1 = require("./SettingNumber");
|
|
8
|
-
const SettingText_1 = require("./SettingText");
|
|
9
|
-
const SettingOption_1 = require("./SettingOption");
|
|
10
|
-
const EventEmitter_1 = require("../Util/EventEmitter");
|
|
11
|
-
/**
|
|
12
|
-
* A collection of flags that can be toggled and are core to all Pixel Streaming experiences.
|
|
13
|
-
* These are used in the `Config.Flags` map.
|
|
14
|
-
*/
|
|
15
|
-
class Flags {
|
|
16
|
-
}
|
|
17
|
-
exports.Flags = Flags;
|
|
18
|
-
Flags.AutoConnect = 'AutoConnect';
|
|
19
|
-
Flags.AutoPlayVideo = 'AutoPlayVideo';
|
|
20
|
-
Flags.AFKDetection = 'TimeoutIfIdle';
|
|
21
|
-
Flags.HoveringMouseMode = 'HoveringMouse';
|
|
22
|
-
Flags.ForceMonoAudio = 'ForceMonoAudio';
|
|
23
|
-
Flags.ForceTURN = 'ForceTURN';
|
|
24
|
-
Flags.FakeMouseWithTouches = 'FakeMouseWithTouches';
|
|
25
|
-
Flags.IsQualityController = 'ControlsQuality';
|
|
26
|
-
Flags.MatchViewportResolution = 'MatchViewportRes';
|
|
27
|
-
Flags.StartVideoMuted = 'StartVideoMuted';
|
|
28
|
-
Flags.SuppressBrowserKeys = 'SuppressBrowserKeys';
|
|
29
|
-
Flags.UseMic = 'UseMic';
|
|
30
|
-
Flags.UseCamera = 'UseCamera';
|
|
31
|
-
Flags.KeyboardInput = 'KeyboardInput';
|
|
32
|
-
Flags.MouseInput = 'MouseInput';
|
|
33
|
-
Flags.TouchInput = 'TouchInput';
|
|
34
|
-
Flags.GamepadInput = 'GamepadInput';
|
|
35
|
-
Flags.XRControllerInput = 'XRControllerInput';
|
|
36
|
-
Flags.WaitForStreamer = 'WaitForStreamer';
|
|
37
|
-
Flags.HideUI = 'HideUI';
|
|
38
|
-
const isFlagId = (id) => Object.getOwnPropertyNames(Flags).some((name) => Flags[name] === id);
|
|
39
|
-
/**
|
|
40
|
-
* A collection of numeric parameters that are core to all Pixel Streaming experiences.
|
|
41
|
-
*
|
|
42
|
-
*/
|
|
43
|
-
class NumericParameters {
|
|
44
|
-
}
|
|
45
|
-
exports.NumericParameters = NumericParameters;
|
|
46
|
-
NumericParameters.AFKTimeoutSecs = 'AFKTimeout';
|
|
47
|
-
NumericParameters.AFKCountdownSecs = 'AFKCountdown';
|
|
48
|
-
NumericParameters.MinQP = 'MinQP';
|
|
49
|
-
NumericParameters.MaxQP = 'MaxQP';
|
|
50
|
-
NumericParameters.WebRTCFPS = 'WebRTCFPS';
|
|
51
|
-
NumericParameters.WebRTCMinBitrate = 'WebRTCMinBitrate';
|
|
52
|
-
NumericParameters.WebRTCMaxBitrate = 'WebRTCMaxBitrate';
|
|
53
|
-
NumericParameters.MaxReconnectAttempts = 'MaxReconnectAttempts';
|
|
54
|
-
NumericParameters.StreamerAutoJoinInterval = 'StreamerAutoJoinInterval';
|
|
55
|
-
const isNumericId = (id) => Object.getOwnPropertyNames(NumericParameters).some((name) => NumericParameters[name] === id);
|
|
56
|
-
/**
|
|
57
|
-
* A collection of textual parameters that are core to all Pixel Streaming experiences.
|
|
58
|
-
*
|
|
59
|
-
*/
|
|
60
|
-
class TextParameters {
|
|
61
|
-
}
|
|
62
|
-
exports.TextParameters = TextParameters;
|
|
63
|
-
TextParameters.SignallingServerUrl = 'ss';
|
|
64
|
-
const isTextId = (id) => Object.getOwnPropertyNames(TextParameters).some((name) => TextParameters[name] === id);
|
|
65
|
-
/**
|
|
66
|
-
* A collection of enum based parameters that are core to all Pixel Streaming experiences.
|
|
67
|
-
*
|
|
68
|
-
*/
|
|
69
|
-
class OptionParameters {
|
|
70
|
-
}
|
|
71
|
-
exports.OptionParameters = OptionParameters;
|
|
72
|
-
OptionParameters.PreferredCodec = 'PreferredCodec';
|
|
73
|
-
OptionParameters.StreamerId = 'StreamerId';
|
|
74
|
-
const isOptionId = (id) => Object.getOwnPropertyNames(OptionParameters).some((name) => OptionParameters[name] === id);
|
|
75
|
-
class Config {
|
|
76
|
-
// ------------ Settings -----------------
|
|
77
|
-
constructor(config = {}) {
|
|
78
|
-
/* A map of flags that can be toggled - options that can be set in the application - e.g. Use Mic? */
|
|
79
|
-
this.flags = new Map();
|
|
80
|
-
/* A map of numerical settings - options that can be in the application - e.g. MinBitrate */
|
|
81
|
-
this.numericParameters = new Map();
|
|
82
|
-
/* A map of text settings - e.g. signalling server url */
|
|
83
|
-
this.textParameters = new Map();
|
|
84
|
-
/* A map of enum based settings - e.g. preferred codec */
|
|
85
|
-
this.optionParameters = new Map();
|
|
86
|
-
const { initialSettings, useUrlParams } = config;
|
|
87
|
-
this._useUrlParams = !!useUrlParams;
|
|
88
|
-
this.populateDefaultSettings(this._useUrlParams, initialSettings);
|
|
89
|
-
}
|
|
90
|
-
/**
|
|
91
|
-
* True if reading configuration initial values from URL parameters, and
|
|
92
|
-
* persisting changes in URL when changed.
|
|
93
|
-
*/
|
|
94
|
-
get useUrlParams() {
|
|
95
|
-
return this._useUrlParams;
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* Populate the default settings for a Pixel Streaming application
|
|
99
|
-
*/
|
|
100
|
-
populateDefaultSettings(useUrlParams, settings) {
|
|
101
|
-
/**
|
|
102
|
-
* Text Parameters
|
|
103
|
-
*/
|
|
104
|
-
this.textParameters.set(TextParameters.SignallingServerUrl, new SettingText_1.SettingText(TextParameters.SignallingServerUrl, 'Signalling url', 'Url of the signalling server', settings && Object.prototype.hasOwnProperty.call(settings, TextParameters.SignallingServerUrl)
|
|
105
|
-
? settings[TextParameters.SignallingServerUrl]
|
|
106
|
-
: (location.protocol === 'https:' ? 'wss://' : 'ws://') +
|
|
107
|
-
window.location.hostname +
|
|
108
|
-
// for readability, we omit the port if it's 80
|
|
109
|
-
(window.location.port === '80' || window.location.port === ''
|
|
110
|
-
? ''
|
|
111
|
-
: `:${window.location.port}`), useUrlParams));
|
|
112
|
-
this.optionParameters.set(OptionParameters.StreamerId, new SettingOption_1.SettingOption(OptionParameters.StreamerId, 'Streamer ID', 'The ID of the streamer to stream.', settings && Object.prototype.hasOwnProperty.call(settings, OptionParameters.StreamerId)
|
|
113
|
-
? settings[OptionParameters.StreamerId]
|
|
114
|
-
: '', settings && Object.prototype.hasOwnProperty.call(settings, OptionParameters.StreamerId)
|
|
115
|
-
? [settings[OptionParameters.StreamerId]]
|
|
116
|
-
: undefined, useUrlParams));
|
|
117
|
-
const getBrowserSupportedVideoCodecs = function () {
|
|
118
|
-
const browserSupportedCodecs = [];
|
|
119
|
-
// Try get the info needed from the RTCRtpReceiver. This is only available on chrome
|
|
120
|
-
if (!RTCRtpReceiver.getCapabilities) {
|
|
121
|
-
lib_pixelstreamingcommon_ue5_5_1.Logger.Warning('RTCRtpReceiver.getCapabilities API is not available in your browser, defaulting to guess that we support H.264.');
|
|
122
|
-
browserSupportedCodecs.push('H264 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42e01f');
|
|
123
|
-
return browserSupportedCodecs;
|
|
124
|
-
}
|
|
125
|
-
const matcher = /(VP\d|H26\d|AV1).*/;
|
|
126
|
-
const codecs = RTCRtpReceiver.getCapabilities('video').codecs;
|
|
127
|
-
codecs.forEach((codec) => {
|
|
128
|
-
const str = codec.mimeType.split('/')[1] + ' ' + (codec.sdpFmtpLine || '');
|
|
129
|
-
const match = matcher.exec(str);
|
|
130
|
-
if (match !== null) {
|
|
131
|
-
browserSupportedCodecs.push(str);
|
|
132
|
-
}
|
|
133
|
-
});
|
|
134
|
-
return browserSupportedCodecs;
|
|
135
|
-
};
|
|
136
|
-
const getDefaultVideoCodec = function () {
|
|
137
|
-
const videoCodecs = getBrowserSupportedVideoCodecs();
|
|
138
|
-
// If only one option, then select that.
|
|
139
|
-
if (videoCodecs.length == 1) {
|
|
140
|
-
return videoCodecs[0];
|
|
141
|
-
}
|
|
142
|
-
else if (videoCodecs.length > 0) {
|
|
143
|
-
const defaultCodec = videoCodecs[0];
|
|
144
|
-
for (const codec of videoCodecs) {
|
|
145
|
-
if (codec.startsWith('H264')) {
|
|
146
|
-
return codec;
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
return defaultCodec;
|
|
150
|
-
}
|
|
151
|
-
lib_pixelstreamingcommon_ue5_5_1.Logger.Error('Could not find any reasonable video codec to assign as a default.');
|
|
152
|
-
return '';
|
|
153
|
-
};
|
|
154
|
-
const matchSpecifiedCodecToClosestSupported = function (specifiedCodec) {
|
|
155
|
-
const browserSupportedCodecs = getBrowserSupportedVideoCodecs();
|
|
156
|
-
// Codec supplied in url param is an exact match for the browser codec.
|
|
157
|
-
// (e.g. H264 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42e01f)
|
|
158
|
-
if (browserSupportedCodecs.includes(specifiedCodec)) {
|
|
159
|
-
return specifiedCodec;
|
|
160
|
-
}
|
|
161
|
-
// Try to match the start of whatever is passed into the url parameter with what the browser supports
|
|
162
|
-
for (const browserCodec of browserSupportedCodecs) {
|
|
163
|
-
if (browserCodec.startsWith(specifiedCodec)) {
|
|
164
|
-
return browserCodec;
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
// If we weren't able to match, just return the codec as from the URL as-is.
|
|
168
|
-
return specifiedCodec;
|
|
169
|
-
};
|
|
170
|
-
/**
|
|
171
|
-
* Enum Parameters
|
|
172
|
-
*/
|
|
173
|
-
this.optionParameters.set(OptionParameters.PreferredCodec, new SettingOption_1.SettingOption(OptionParameters.PreferredCodec, 'Preferred Codec', 'The preferred codec to be used during codec negotiation', settings && Object.prototype.hasOwnProperty.call(settings, OptionParameters.PreferredCodec)
|
|
174
|
-
? matchSpecifiedCodecToClosestSupported(settings[OptionParameters.PreferredCodec])
|
|
175
|
-
: getDefaultVideoCodec(), getBrowserSupportedVideoCodecs(), useUrlParams, matchSpecifiedCodecToClosestSupported));
|
|
176
|
-
/**
|
|
177
|
-
* Boolean parameters
|
|
178
|
-
*/
|
|
179
|
-
this.flags.set(Flags.AutoConnect, new SettingFlag_1.SettingFlag(Flags.AutoConnect, 'Auto connect to stream', 'Whether we should attempt to auto connect to the signalling server or show a click to start prompt.', settings && Object.prototype.hasOwnProperty.call(settings, Flags.AutoConnect)
|
|
180
|
-
? settings[Flags.AutoConnect]
|
|
181
|
-
: false, useUrlParams));
|
|
182
|
-
this.flags.set(Flags.AutoPlayVideo, new SettingFlag_1.SettingFlag(Flags.AutoPlayVideo, 'Auto play video', 'When video is ready automatically start playing it as opposed to showing a play button.', settings && Object.prototype.hasOwnProperty.call(settings, Flags.AutoPlayVideo)
|
|
183
|
-
? settings[Flags.AutoPlayVideo]
|
|
184
|
-
: true, useUrlParams));
|
|
185
|
-
this.flags.set(Flags.UseMic, new SettingFlag_1.SettingFlag(Flags.UseMic, 'Use microphone', 'Make browser request microphone access and open an input audio track.', settings && Object.prototype.hasOwnProperty.call(settings, Flags.UseMic)
|
|
186
|
-
? settings[Flags.UseMic]
|
|
187
|
-
: false, useUrlParams));
|
|
188
|
-
this.flags.set(Flags.UseCamera, new SettingFlag_1.SettingFlag(Flags.UseCamera, 'Use webcam', 'Make browser request webcam access and open a input video track.', settings && Object.prototype.hasOwnProperty.call(settings, Flags.UseCamera)
|
|
189
|
-
? settings[Flags.UseCamera]
|
|
190
|
-
: false, useUrlParams));
|
|
191
|
-
this.flags.set(Flags.StartVideoMuted, new SettingFlag_1.SettingFlag(Flags.StartVideoMuted, 'Start video muted', 'Video will start muted if true.', settings && Object.prototype.hasOwnProperty.call(settings, Flags.StartVideoMuted)
|
|
192
|
-
? settings[Flags.StartVideoMuted]
|
|
193
|
-
: false, useUrlParams));
|
|
194
|
-
this.flags.set(Flags.SuppressBrowserKeys, new SettingFlag_1.SettingFlag(Flags.SuppressBrowserKeys, 'Suppress browser keys', 'Suppress certain browser keys that we use in UE, for example F5 to show shader complexity instead of refresh the page.', settings && Object.prototype.hasOwnProperty.call(settings, Flags.SuppressBrowserKeys)
|
|
195
|
-
? settings[Flags.SuppressBrowserKeys]
|
|
196
|
-
: true, useUrlParams));
|
|
197
|
-
this.flags.set(Flags.IsQualityController, new SettingFlag_1.SettingFlag(Flags.IsQualityController, 'Is quality controller?', 'True if this peer controls stream quality', settings && Object.prototype.hasOwnProperty.call(settings, Flags.IsQualityController)
|
|
198
|
-
? settings[Flags.IsQualityController]
|
|
199
|
-
: true, useUrlParams));
|
|
200
|
-
this.flags.set(Flags.ForceMonoAudio, new SettingFlag_1.SettingFlag(Flags.ForceMonoAudio, 'Force mono audio', 'Force browser to request mono audio in the SDP', settings && Object.prototype.hasOwnProperty.call(settings, Flags.ForceMonoAudio)
|
|
201
|
-
? settings[Flags.ForceMonoAudio]
|
|
202
|
-
: false, useUrlParams));
|
|
203
|
-
this.flags.set(Flags.ForceTURN, new SettingFlag_1.SettingFlag(Flags.ForceTURN, 'Force TURN', 'Only generate TURN/Relayed ICE candidates.', settings && Object.prototype.hasOwnProperty.call(settings, Flags.ForceTURN)
|
|
204
|
-
? settings[Flags.ForceTURN]
|
|
205
|
-
: false, useUrlParams));
|
|
206
|
-
this.flags.set(Flags.AFKDetection, new SettingFlag_1.SettingFlag(Flags.AFKDetection, 'AFK if idle', 'Timeout the experience if user is AFK for a period.', settings && Object.prototype.hasOwnProperty.call(settings, Flags.AFKDetection)
|
|
207
|
-
? settings[Flags.AFKDetection]
|
|
208
|
-
: false, useUrlParams));
|
|
209
|
-
this.flags.set(Flags.MatchViewportResolution, new SettingFlag_1.SettingFlag(Flags.MatchViewportResolution, 'Match viewport resolution', 'Pixel Streaming will be instructed to dynamically resize the video stream to match the size of the video element.', settings && Object.prototype.hasOwnProperty.call(settings, Flags.MatchViewportResolution)
|
|
210
|
-
? settings[Flags.MatchViewportResolution]
|
|
211
|
-
: false, useUrlParams));
|
|
212
|
-
this.flags.set(Flags.HoveringMouseMode, new SettingFlag_1.SettingFlag(Flags.HoveringMouseMode, 'Control Scheme: Locked Mouse', 'Either locked mouse, where the pointer is consumed by the video and locked to it, or hovering mouse, where the mouse is not consumed.', settings && Object.prototype.hasOwnProperty.call(settings, Flags.HoveringMouseMode)
|
|
213
|
-
? settings[Flags.HoveringMouseMode]
|
|
214
|
-
: false, useUrlParams, (isHoveringMouse, setting) => {
|
|
215
|
-
setting.label = `Control Scheme: ${isHoveringMouse ? 'Hovering' : 'Locked'} Mouse`;
|
|
216
|
-
}));
|
|
217
|
-
this.flags.set(Flags.FakeMouseWithTouches, new SettingFlag_1.SettingFlag(Flags.FakeMouseWithTouches, 'Fake mouse with touches', 'A single finger touch is converted into a mouse event. This allows a non-touch application to be controlled partially via a touch device.', settings && Object.prototype.hasOwnProperty.call(settings, Flags.FakeMouseWithTouches)
|
|
218
|
-
? settings[Flags.FakeMouseWithTouches]
|
|
219
|
-
: false, useUrlParams));
|
|
220
|
-
this.flags.set(Flags.KeyboardInput, new SettingFlag_1.SettingFlag(Flags.KeyboardInput, 'Keyboard input', 'If enabled, send keyboard events to streamer', settings && Object.prototype.hasOwnProperty.call(settings, Flags.KeyboardInput)
|
|
221
|
-
? settings[Flags.KeyboardInput]
|
|
222
|
-
: true, useUrlParams));
|
|
223
|
-
this.flags.set(Flags.MouseInput, new SettingFlag_1.SettingFlag(Flags.MouseInput, 'Mouse input', 'If enabled, send mouse events to streamer', settings && Object.prototype.hasOwnProperty.call(settings, Flags.MouseInput)
|
|
224
|
-
? settings[Flags.MouseInput]
|
|
225
|
-
: true, useUrlParams));
|
|
226
|
-
this.flags.set(Flags.TouchInput, new SettingFlag_1.SettingFlag(Flags.TouchInput, 'Touch input', 'If enabled, send touch events to streamer', settings && Object.prototype.hasOwnProperty.call(settings, Flags.TouchInput)
|
|
227
|
-
? settings[Flags.TouchInput]
|
|
228
|
-
: true, useUrlParams));
|
|
229
|
-
this.flags.set(Flags.GamepadInput, new SettingFlag_1.SettingFlag(Flags.GamepadInput, 'Gamepad input', 'If enabled, send gamepad events to streamer', settings && Object.prototype.hasOwnProperty.call(settings, Flags.GamepadInput)
|
|
230
|
-
? settings[Flags.GamepadInput]
|
|
231
|
-
: true, useUrlParams));
|
|
232
|
-
this.flags.set(Flags.XRControllerInput, new SettingFlag_1.SettingFlag(Flags.XRControllerInput, 'XR controller input', 'If enabled, send XR controller events to streamer', settings && Object.prototype.hasOwnProperty.call(settings, Flags.XRControllerInput)
|
|
233
|
-
? settings[Flags.XRControllerInput]
|
|
234
|
-
: true, useUrlParams));
|
|
235
|
-
this.flags.set(Flags.WaitForStreamer, new SettingFlag_1.SettingFlag(Flags.WaitForStreamer, 'Wait for streamer', 'Will continue trying to connect to the first streamer available.', settings && Object.prototype.hasOwnProperty.call(settings, Flags.WaitForStreamer)
|
|
236
|
-
? settings[Flags.WaitForStreamer]
|
|
237
|
-
: true, useUrlParams));
|
|
238
|
-
this.flags.set(Flags.HideUI, new SettingFlag_1.SettingFlag(Flags.HideUI, 'Hide the UI overlay', 'Will hide all UI overlay details', settings && Object.prototype.hasOwnProperty.call(settings, Flags.HideUI)
|
|
239
|
-
? settings[Flags.HideUI]
|
|
240
|
-
: false, useUrlParams));
|
|
241
|
-
/**
|
|
242
|
-
* Numeric parameters
|
|
243
|
-
*/
|
|
244
|
-
this.numericParameters.set(NumericParameters.AFKTimeoutSecs, new SettingNumber_1.SettingNumber(NumericParameters.AFKTimeoutSecs, 'AFK timeout', 'The time (in seconds) it takes for the application to time out if AFK timeout is enabled.', 0 /*min*/, null /*max*/, settings && Object.prototype.hasOwnProperty.call(settings, NumericParameters.AFKTimeoutSecs)
|
|
245
|
-
? settings[NumericParameters.AFKTimeoutSecs]
|
|
246
|
-
: 120 /*value*/, useUrlParams));
|
|
247
|
-
this.numericParameters.set(NumericParameters.AFKCountdownSecs, new SettingNumber_1.SettingNumber(NumericParameters.AFKCountdownSecs, 'AFK countdown', 'The time (in seconds) for a user to respond before the stream is ended after an AFK timeout.', 10 /*min*/, null /*max*/, 10 /*value*/, useUrlParams));
|
|
248
|
-
this.numericParameters.set(NumericParameters.MaxReconnectAttempts, new SettingNumber_1.SettingNumber(NumericParameters.MaxReconnectAttempts, 'Max Reconnects', 'Maximum number of reconnects the application will attempt when a streamer disconnects.', 0 /*min*/, 999 /*max*/, settings &&
|
|
249
|
-
Object.prototype.hasOwnProperty.call(settings, NumericParameters.MaxReconnectAttempts)
|
|
250
|
-
? settings[NumericParameters.MaxReconnectAttempts]
|
|
251
|
-
: 3 /*value*/, useUrlParams));
|
|
252
|
-
this.numericParameters.set(NumericParameters.MinQP, new SettingNumber_1.SettingNumber(NumericParameters.MinQP, 'Min QP', 'The lower bound for the quantization parameter (QP) of the encoder. 0 = Best quality, 51 = worst quality.', 0 /*min*/, 51 /*max*/, settings && Object.prototype.hasOwnProperty.call(settings, NumericParameters.MinQP)
|
|
253
|
-
? settings[NumericParameters.MinQP]
|
|
254
|
-
: 0 /*value*/, useUrlParams));
|
|
255
|
-
this.numericParameters.set(NumericParameters.MaxQP, new SettingNumber_1.SettingNumber(NumericParameters.MaxQP, 'Max QP', 'The upper bound for the quantization parameter (QP) of the encoder. 0 = Best quality, 51 = worst quality.', 0 /*min*/, 51 /*max*/, settings && Object.prototype.hasOwnProperty.call(settings, NumericParameters.MaxQP)
|
|
256
|
-
? settings[NumericParameters.MaxQP]
|
|
257
|
-
: 51 /*value*/, useUrlParams));
|
|
258
|
-
this.numericParameters.set(NumericParameters.WebRTCFPS, new SettingNumber_1.SettingNumber(NumericParameters.WebRTCFPS, 'Max FPS', 'The maximum FPS that WebRTC will try to transmit frames at.', 1 /*min*/, 999 /*max*/, settings && Object.prototype.hasOwnProperty.call(settings, NumericParameters.WebRTCFPS)
|
|
259
|
-
? settings[NumericParameters.WebRTCFPS]
|
|
260
|
-
: 60 /*value*/, useUrlParams));
|
|
261
|
-
this.numericParameters.set(NumericParameters.WebRTCMinBitrate, new SettingNumber_1.SettingNumber(NumericParameters.WebRTCMinBitrate, 'Min Bitrate (kbps)', 'The minimum bitrate that WebRTC should use.', 0 /*min*/, 500000 /*max*/, settings && Object.prototype.hasOwnProperty.call(settings, NumericParameters.WebRTCMinBitrate)
|
|
262
|
-
? settings[NumericParameters.WebRTCMinBitrate]
|
|
263
|
-
: 0 /*value*/, useUrlParams));
|
|
264
|
-
this.numericParameters.set(NumericParameters.WebRTCMaxBitrate, new SettingNumber_1.SettingNumber(NumericParameters.WebRTCMaxBitrate, 'Max Bitrate (kbps)', 'The maximum bitrate that WebRTC should use.', 0 /*min*/, 500000 /*max*/, settings && Object.prototype.hasOwnProperty.call(settings, NumericParameters.WebRTCMaxBitrate)
|
|
265
|
-
? settings[NumericParameters.WebRTCMaxBitrate]
|
|
266
|
-
: 0 /*value*/, useUrlParams));
|
|
267
|
-
this.numericParameters.set(NumericParameters.StreamerAutoJoinInterval, new SettingNumber_1.SettingNumber(NumericParameters.StreamerAutoJoinInterval, 'Streamer Auto Join Interval (ms)', 'Delay between retries when waiting for an available streamer.', 500 /*min*/, 900000 /*max*/, settings &&
|
|
268
|
-
Object.prototype.hasOwnProperty.call(settings, NumericParameters.StreamerAutoJoinInterval)
|
|
269
|
-
? settings[NumericParameters.StreamerAutoJoinInterval]
|
|
270
|
-
: 3000 /*value*/, useUrlParams));
|
|
271
|
-
}
|
|
272
|
-
/**
|
|
273
|
-
* Add a callback to fire when the numeric setting is toggled.
|
|
274
|
-
* @param id The id of the flag.
|
|
275
|
-
* @param onChangedListener The callback to fire when the numeric value changes.
|
|
276
|
-
*/
|
|
277
|
-
_addOnNumericSettingChangedListener(id, onChangedListener) {
|
|
278
|
-
if (this.numericParameters.has(id)) {
|
|
279
|
-
this.numericParameters.get(id).addOnChangedListener(onChangedListener);
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
_addOnOptionSettingChangedListener(id, onChangedListener) {
|
|
283
|
-
if (this.optionParameters.has(id)) {
|
|
284
|
-
this.optionParameters.get(id).addOnChangedListener(onChangedListener);
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
/**
|
|
288
|
-
* @param id The id of the numeric setting we are interested in getting a value for.
|
|
289
|
-
* @returns The numeric value stored in the parameter with the passed id.
|
|
290
|
-
*/
|
|
291
|
-
getNumericSettingValue(id) {
|
|
292
|
-
if (this.numericParameters.has(id)) {
|
|
293
|
-
return this.numericParameters.get(id).number;
|
|
294
|
-
}
|
|
295
|
-
else {
|
|
296
|
-
throw new Error(`There is no numeric setting with the id of ${id}`);
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
/**
|
|
300
|
-
* @param id The id of the text setting we are interested in getting a value for.
|
|
301
|
-
* @returns The text value stored in the parameter with the passed id.
|
|
302
|
-
*/
|
|
303
|
-
getTextSettingValue(id) {
|
|
304
|
-
if (this.textParameters.has(id)) {
|
|
305
|
-
return this.textParameters.get(id).value;
|
|
306
|
-
}
|
|
307
|
-
else {
|
|
308
|
-
throw new Error(`There is no numeric setting with the id of ${id}`);
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
/**
|
|
312
|
-
* Set number in the setting.
|
|
313
|
-
* @param id The id of the numeric setting we are interested in.
|
|
314
|
-
* @param value The numeric value to set.
|
|
315
|
-
*/
|
|
316
|
-
setNumericSetting(id, value) {
|
|
317
|
-
if (this.numericParameters.has(id)) {
|
|
318
|
-
this.numericParameters.get(id).number = value;
|
|
319
|
-
}
|
|
320
|
-
else {
|
|
321
|
-
throw new Error(`There is no numeric setting with the id of ${id}`);
|
|
322
|
-
}
|
|
323
|
-
}
|
|
324
|
-
/**
|
|
325
|
-
* Add a callback to fire when the flag is toggled.
|
|
326
|
-
* @param id The id of the flag.
|
|
327
|
-
* @param onChangeListener The callback to fire when the value changes.
|
|
328
|
-
*/
|
|
329
|
-
_addOnSettingChangedListener(id, onChangeListener) {
|
|
330
|
-
if (this.flags.has(id)) {
|
|
331
|
-
this.flags.get(id).onChange = onChangeListener;
|
|
332
|
-
}
|
|
333
|
-
}
|
|
334
|
-
/**
|
|
335
|
-
* Add a callback to fire when the text is changed.
|
|
336
|
-
* @param id The id of the flag.
|
|
337
|
-
* @param onChangeListener The callback to fire when the value changes.
|
|
338
|
-
*/
|
|
339
|
-
_addOnTextSettingChangedListener(id, onChangeListener) {
|
|
340
|
-
if (this.textParameters.has(id)) {
|
|
341
|
-
this.textParameters.get(id).onChange = onChangeListener;
|
|
342
|
-
}
|
|
343
|
-
}
|
|
344
|
-
/**
|
|
345
|
-
* Get the option which has the given id.
|
|
346
|
-
* @param id The id of the option.
|
|
347
|
-
* @returns The SettingOption object matching id
|
|
348
|
-
*/
|
|
349
|
-
getSettingOption(id) {
|
|
350
|
-
return this.optionParameters.get(id);
|
|
351
|
-
}
|
|
352
|
-
/**
|
|
353
|
-
* Get the value of the configuration flag which has the given id.
|
|
354
|
-
* @param id The unique id for the flag.
|
|
355
|
-
* @returns True if the flag is enabled.
|
|
356
|
-
*/
|
|
357
|
-
isFlagEnabled(id) {
|
|
358
|
-
return this.flags.get(id).flag;
|
|
359
|
-
}
|
|
360
|
-
/**
|
|
361
|
-
* Set flag to be enabled/disabled.
|
|
362
|
-
* @param id The id of the flag to toggle.
|
|
363
|
-
* @param flagEnabled True if the flag should be enabled.
|
|
364
|
-
*/
|
|
365
|
-
setFlagEnabled(id, flagEnabled) {
|
|
366
|
-
if (!this.flags.has(id)) {
|
|
367
|
-
lib_pixelstreamingcommon_ue5_5_1.Logger.Warning(`Cannot toggle flag called ${id} - it does not exist in the Config.flags map.`);
|
|
368
|
-
}
|
|
369
|
-
else {
|
|
370
|
-
this.flags.get(id).flag = flagEnabled;
|
|
371
|
-
}
|
|
372
|
-
}
|
|
373
|
-
/**
|
|
374
|
-
* Set the text setting.
|
|
375
|
-
* @param id The id of the setting
|
|
376
|
-
* @param settingValue The value to set in the setting.
|
|
377
|
-
*/
|
|
378
|
-
setTextSetting(id, settingValue) {
|
|
379
|
-
if (!this.textParameters.has(id)) {
|
|
380
|
-
lib_pixelstreamingcommon_ue5_5_1.Logger.Warning(`Cannot set text setting called ${id} - it does not exist in the Config.textParameters map.`);
|
|
381
|
-
}
|
|
382
|
-
else {
|
|
383
|
-
this.textParameters.get(id).text = settingValue;
|
|
384
|
-
}
|
|
385
|
-
}
|
|
386
|
-
/**
|
|
387
|
-
* Set the option setting list of options.
|
|
388
|
-
* @param id The id of the setting
|
|
389
|
-
* @param settingOptions The values the setting could take
|
|
390
|
-
*/
|
|
391
|
-
setOptionSettingOptions(id, settingOptions) {
|
|
392
|
-
if (!this.optionParameters.has(id)) {
|
|
393
|
-
lib_pixelstreamingcommon_ue5_5_1.Logger.Warning(`Cannot set text setting called ${id} - it does not exist in the Config.optionParameters map.`);
|
|
394
|
-
}
|
|
395
|
-
else {
|
|
396
|
-
this.optionParameters.get(id).options = settingOptions;
|
|
397
|
-
}
|
|
398
|
-
}
|
|
399
|
-
/**
|
|
400
|
-
* Set option enum settings selected option.
|
|
401
|
-
* @param id The id of the setting
|
|
402
|
-
* @param settingOptions The value to select out of all the options
|
|
403
|
-
*/
|
|
404
|
-
setOptionSettingValue(id, settingValue) {
|
|
405
|
-
if (!this.optionParameters.has(id)) {
|
|
406
|
-
lib_pixelstreamingcommon_ue5_5_1.Logger.Warning(`Cannot set text setting called ${id} - it does not exist in the Config.enumParameters map.`);
|
|
407
|
-
}
|
|
408
|
-
else {
|
|
409
|
-
const optionSetting = this.optionParameters.get(id);
|
|
410
|
-
const existingOptions = optionSetting.options;
|
|
411
|
-
if (!existingOptions.includes(settingValue)) {
|
|
412
|
-
existingOptions.push(settingValue);
|
|
413
|
-
optionSetting.options = existingOptions;
|
|
414
|
-
}
|
|
415
|
-
optionSetting.selected = settingValue;
|
|
416
|
-
}
|
|
417
|
-
}
|
|
418
|
-
/**
|
|
419
|
-
* Set the label for the flag.
|
|
420
|
-
* @param id The id of the flag.
|
|
421
|
-
* @param label The new label to use for the flag.
|
|
422
|
-
*/
|
|
423
|
-
setFlagLabel(id, label) {
|
|
424
|
-
if (!this.flags.has(id)) {
|
|
425
|
-
lib_pixelstreamingcommon_ue5_5_1.Logger.Warning(`Cannot set label for flag called ${id} - it does not exist in the Config.flags map.`);
|
|
426
|
-
}
|
|
427
|
-
else {
|
|
428
|
-
this.flags.get(id).label = label;
|
|
429
|
-
}
|
|
430
|
-
}
|
|
431
|
-
/**
|
|
432
|
-
* Set a subset of all settings in one function call.
|
|
433
|
-
*
|
|
434
|
-
* @param settings A (partial) list of settings to set
|
|
435
|
-
*/
|
|
436
|
-
setSettings(settings) {
|
|
437
|
-
for (const key of Object.keys(settings)) {
|
|
438
|
-
if (isFlagId(key)) {
|
|
439
|
-
this.setFlagEnabled(key, settings[key]);
|
|
440
|
-
}
|
|
441
|
-
else if (isNumericId(key)) {
|
|
442
|
-
this.setNumericSetting(key, settings[key]);
|
|
443
|
-
}
|
|
444
|
-
else if (isTextId(key)) {
|
|
445
|
-
this.setTextSetting(key, settings[key]);
|
|
446
|
-
}
|
|
447
|
-
else if (isOptionId(key)) {
|
|
448
|
-
this.setOptionSettingValue(key, settings[key]);
|
|
449
|
-
}
|
|
450
|
-
}
|
|
451
|
-
}
|
|
452
|
-
/**
|
|
453
|
-
* Get all settings
|
|
454
|
-
* @returns All setting values as an object with setting ids as keys
|
|
455
|
-
*/
|
|
456
|
-
getSettings() {
|
|
457
|
-
const settings = {};
|
|
458
|
-
for (const [key, value] of this.flags.entries()) {
|
|
459
|
-
settings[key] = value.flag;
|
|
460
|
-
}
|
|
461
|
-
for (const [key, value] of this.numericParameters.entries()) {
|
|
462
|
-
settings[key] = value.number;
|
|
463
|
-
}
|
|
464
|
-
for (const [key, value] of this.textParameters.entries()) {
|
|
465
|
-
settings[key] = value.text;
|
|
466
|
-
}
|
|
467
|
-
for (const [key, value] of this.optionParameters.entries()) {
|
|
468
|
-
settings[key] = value.selected;
|
|
469
|
-
}
|
|
470
|
-
return settings;
|
|
471
|
-
}
|
|
472
|
-
/**
|
|
473
|
-
* Get all Flag settings as an array.
|
|
474
|
-
* @returns All SettingFlag objects
|
|
475
|
-
*/
|
|
476
|
-
getFlags() {
|
|
477
|
-
return Array.from(this.flags.values());
|
|
478
|
-
}
|
|
479
|
-
/**
|
|
480
|
-
* Get all Text settings as an array.
|
|
481
|
-
* @returns All SettingText objects
|
|
482
|
-
*/
|
|
483
|
-
getTextSettings() {
|
|
484
|
-
return Array.from(this.textParameters.values());
|
|
485
|
-
}
|
|
486
|
-
/**
|
|
487
|
-
* Get all Number settings as an array.
|
|
488
|
-
* @returns All SettingNumber objects
|
|
489
|
-
*/
|
|
490
|
-
getNumericSettings() {
|
|
491
|
-
return Array.from(this.numericParameters.values());
|
|
492
|
-
}
|
|
493
|
-
/**
|
|
494
|
-
* Get all Option settings as an array.
|
|
495
|
-
* @returns All SettingOption objects
|
|
496
|
-
*/
|
|
497
|
-
getOptionSettings() {
|
|
498
|
-
return Array.from(this.optionParameters.values());
|
|
499
|
-
}
|
|
500
|
-
/**
|
|
501
|
-
* Emit events when settings change.
|
|
502
|
-
* @param eventEmitter
|
|
503
|
-
*/
|
|
504
|
-
_registerOnChangeEvents(eventEmitter) {
|
|
505
|
-
for (const key of this.flags.keys()) {
|
|
506
|
-
const flag = this.flags.get(key);
|
|
507
|
-
if (flag) {
|
|
508
|
-
flag.onChangeEmit = (newValue) => eventEmitter.dispatchEvent(new EventEmitter_1.SettingsChangedEvent({
|
|
509
|
-
id: flag.id,
|
|
510
|
-
type: 'flag',
|
|
511
|
-
value: newValue,
|
|
512
|
-
target: flag
|
|
513
|
-
}));
|
|
514
|
-
}
|
|
515
|
-
}
|
|
516
|
-
for (const key of this.numericParameters.keys()) {
|
|
517
|
-
const number = this.numericParameters.get(key);
|
|
518
|
-
if (number) {
|
|
519
|
-
number.onChangeEmit = (newValue) => eventEmitter.dispatchEvent(new EventEmitter_1.SettingsChangedEvent({
|
|
520
|
-
id: number.id,
|
|
521
|
-
type: 'number',
|
|
522
|
-
value: newValue,
|
|
523
|
-
target: number
|
|
524
|
-
}));
|
|
525
|
-
}
|
|
526
|
-
}
|
|
527
|
-
for (const key of this.textParameters.keys()) {
|
|
528
|
-
const text = this.textParameters.get(key);
|
|
529
|
-
if (text) {
|
|
530
|
-
text.onChangeEmit = (newValue) => eventEmitter.dispatchEvent(new EventEmitter_1.SettingsChangedEvent({
|
|
531
|
-
id: text.id,
|
|
532
|
-
type: 'text',
|
|
533
|
-
value: newValue,
|
|
534
|
-
target: text
|
|
535
|
-
}));
|
|
536
|
-
}
|
|
537
|
-
}
|
|
538
|
-
for (const key of this.optionParameters.keys()) {
|
|
539
|
-
const option = this.optionParameters.get(key);
|
|
540
|
-
if (option) {
|
|
541
|
-
option.onChangeEmit = (newValue) => eventEmitter.dispatchEvent(new EventEmitter_1.SettingsChangedEvent({
|
|
542
|
-
id: option.id,
|
|
543
|
-
type: 'option',
|
|
544
|
-
value: newValue,
|
|
545
|
-
target: option
|
|
546
|
-
}));
|
|
547
|
-
}
|
|
548
|
-
}
|
|
549
|
-
}
|
|
550
|
-
}
|
|
551
|
-
exports.Config = Config;
|
|
552
|
-
/**
|
|
553
|
-
* The enum associated with the mouse being locked or hovering
|
|
554
|
-
*/
|
|
555
|
-
var ControlSchemeType;
|
|
556
|
-
(function (ControlSchemeType) {
|
|
557
|
-
ControlSchemeType[ControlSchemeType["LockedMouse"] = 0] = "LockedMouse";
|
|
558
|
-
ControlSchemeType[ControlSchemeType["HoveringMouse"] = 1] = "HoveringMouse";
|
|
559
|
-
})(ControlSchemeType = exports.ControlSchemeType || (exports.ControlSchemeType = {}));
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.ControlSchemeType = exports.Config = exports.OptionParameters = exports.TextParameters = exports.NumericParameters = exports.Flags = void 0;
|
|
5
|
+
const lib_pixelstreamingcommon_ue5_5_1 = require("@epicgames-ps/lib-pixelstreamingcommon-ue5.5");
|
|
6
|
+
const SettingFlag_1 = require("./SettingFlag");
|
|
7
|
+
const SettingNumber_1 = require("./SettingNumber");
|
|
8
|
+
const SettingText_1 = require("./SettingText");
|
|
9
|
+
const SettingOption_1 = require("./SettingOption");
|
|
10
|
+
const EventEmitter_1 = require("../Util/EventEmitter");
|
|
11
|
+
/**
|
|
12
|
+
* A collection of flags that can be toggled and are core to all Pixel Streaming experiences.
|
|
13
|
+
* These are used in the `Config.Flags` map.
|
|
14
|
+
*/
|
|
15
|
+
class Flags {
|
|
16
|
+
}
|
|
17
|
+
exports.Flags = Flags;
|
|
18
|
+
Flags.AutoConnect = 'AutoConnect';
|
|
19
|
+
Flags.AutoPlayVideo = 'AutoPlayVideo';
|
|
20
|
+
Flags.AFKDetection = 'TimeoutIfIdle';
|
|
21
|
+
Flags.HoveringMouseMode = 'HoveringMouse';
|
|
22
|
+
Flags.ForceMonoAudio = 'ForceMonoAudio';
|
|
23
|
+
Flags.ForceTURN = 'ForceTURN';
|
|
24
|
+
Flags.FakeMouseWithTouches = 'FakeMouseWithTouches';
|
|
25
|
+
Flags.IsQualityController = 'ControlsQuality';
|
|
26
|
+
Flags.MatchViewportResolution = 'MatchViewportRes';
|
|
27
|
+
Flags.StartVideoMuted = 'StartVideoMuted';
|
|
28
|
+
Flags.SuppressBrowserKeys = 'SuppressBrowserKeys';
|
|
29
|
+
Flags.UseMic = 'UseMic';
|
|
30
|
+
Flags.UseCamera = 'UseCamera';
|
|
31
|
+
Flags.KeyboardInput = 'KeyboardInput';
|
|
32
|
+
Flags.MouseInput = 'MouseInput';
|
|
33
|
+
Flags.TouchInput = 'TouchInput';
|
|
34
|
+
Flags.GamepadInput = 'GamepadInput';
|
|
35
|
+
Flags.XRControllerInput = 'XRControllerInput';
|
|
36
|
+
Flags.WaitForStreamer = 'WaitForStreamer';
|
|
37
|
+
Flags.HideUI = 'HideUI';
|
|
38
|
+
const isFlagId = (id) => Object.getOwnPropertyNames(Flags).some((name) => Flags[name] === id);
|
|
39
|
+
/**
|
|
40
|
+
* A collection of numeric parameters that are core to all Pixel Streaming experiences.
|
|
41
|
+
*
|
|
42
|
+
*/
|
|
43
|
+
class NumericParameters {
|
|
44
|
+
}
|
|
45
|
+
exports.NumericParameters = NumericParameters;
|
|
46
|
+
NumericParameters.AFKTimeoutSecs = 'AFKTimeout';
|
|
47
|
+
NumericParameters.AFKCountdownSecs = 'AFKCountdown';
|
|
48
|
+
NumericParameters.MinQP = 'MinQP';
|
|
49
|
+
NumericParameters.MaxQP = 'MaxQP';
|
|
50
|
+
NumericParameters.WebRTCFPS = 'WebRTCFPS';
|
|
51
|
+
NumericParameters.WebRTCMinBitrate = 'WebRTCMinBitrate';
|
|
52
|
+
NumericParameters.WebRTCMaxBitrate = 'WebRTCMaxBitrate';
|
|
53
|
+
NumericParameters.MaxReconnectAttempts = 'MaxReconnectAttempts';
|
|
54
|
+
NumericParameters.StreamerAutoJoinInterval = 'StreamerAutoJoinInterval';
|
|
55
|
+
const isNumericId = (id) => Object.getOwnPropertyNames(NumericParameters).some((name) => NumericParameters[name] === id);
|
|
56
|
+
/**
|
|
57
|
+
* A collection of textual parameters that are core to all Pixel Streaming experiences.
|
|
58
|
+
*
|
|
59
|
+
*/
|
|
60
|
+
class TextParameters {
|
|
61
|
+
}
|
|
62
|
+
exports.TextParameters = TextParameters;
|
|
63
|
+
TextParameters.SignallingServerUrl = 'ss';
|
|
64
|
+
const isTextId = (id) => Object.getOwnPropertyNames(TextParameters).some((name) => TextParameters[name] === id);
|
|
65
|
+
/**
|
|
66
|
+
* A collection of enum based parameters that are core to all Pixel Streaming experiences.
|
|
67
|
+
*
|
|
68
|
+
*/
|
|
69
|
+
class OptionParameters {
|
|
70
|
+
}
|
|
71
|
+
exports.OptionParameters = OptionParameters;
|
|
72
|
+
OptionParameters.PreferredCodec = 'PreferredCodec';
|
|
73
|
+
OptionParameters.StreamerId = 'StreamerId';
|
|
74
|
+
const isOptionId = (id) => Object.getOwnPropertyNames(OptionParameters).some((name) => OptionParameters[name] === id);
|
|
75
|
+
class Config {
|
|
76
|
+
// ------------ Settings -----------------
|
|
77
|
+
constructor(config = {}) {
|
|
78
|
+
/* A map of flags that can be toggled - options that can be set in the application - e.g. Use Mic? */
|
|
79
|
+
this.flags = new Map();
|
|
80
|
+
/* A map of numerical settings - options that can be in the application - e.g. MinBitrate */
|
|
81
|
+
this.numericParameters = new Map();
|
|
82
|
+
/* A map of text settings - e.g. signalling server url */
|
|
83
|
+
this.textParameters = new Map();
|
|
84
|
+
/* A map of enum based settings - e.g. preferred codec */
|
|
85
|
+
this.optionParameters = new Map();
|
|
86
|
+
const { initialSettings, useUrlParams } = config;
|
|
87
|
+
this._useUrlParams = !!useUrlParams;
|
|
88
|
+
this.populateDefaultSettings(this._useUrlParams, initialSettings);
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* True if reading configuration initial values from URL parameters, and
|
|
92
|
+
* persisting changes in URL when changed.
|
|
93
|
+
*/
|
|
94
|
+
get useUrlParams() {
|
|
95
|
+
return this._useUrlParams;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Populate the default settings for a Pixel Streaming application
|
|
99
|
+
*/
|
|
100
|
+
populateDefaultSettings(useUrlParams, settings) {
|
|
101
|
+
/**
|
|
102
|
+
* Text Parameters
|
|
103
|
+
*/
|
|
104
|
+
this.textParameters.set(TextParameters.SignallingServerUrl, new SettingText_1.SettingText(TextParameters.SignallingServerUrl, 'Signalling url', 'Url of the signalling server', settings && Object.prototype.hasOwnProperty.call(settings, TextParameters.SignallingServerUrl)
|
|
105
|
+
? settings[TextParameters.SignallingServerUrl]
|
|
106
|
+
: (location.protocol === 'https:' ? 'wss://' : 'ws://') +
|
|
107
|
+
window.location.hostname +
|
|
108
|
+
// for readability, we omit the port if it's 80
|
|
109
|
+
(window.location.port === '80' || window.location.port === ''
|
|
110
|
+
? ''
|
|
111
|
+
: `:${window.location.port}`), useUrlParams));
|
|
112
|
+
this.optionParameters.set(OptionParameters.StreamerId, new SettingOption_1.SettingOption(OptionParameters.StreamerId, 'Streamer ID', 'The ID of the streamer to stream.', settings && Object.prototype.hasOwnProperty.call(settings, OptionParameters.StreamerId)
|
|
113
|
+
? settings[OptionParameters.StreamerId]
|
|
114
|
+
: '', settings && Object.prototype.hasOwnProperty.call(settings, OptionParameters.StreamerId)
|
|
115
|
+
? [settings[OptionParameters.StreamerId]]
|
|
116
|
+
: undefined, useUrlParams));
|
|
117
|
+
const getBrowserSupportedVideoCodecs = function () {
|
|
118
|
+
const browserSupportedCodecs = [];
|
|
119
|
+
// Try get the info needed from the RTCRtpReceiver. This is only available on chrome
|
|
120
|
+
if (!RTCRtpReceiver.getCapabilities) {
|
|
121
|
+
lib_pixelstreamingcommon_ue5_5_1.Logger.Warning('RTCRtpReceiver.getCapabilities API is not available in your browser, defaulting to guess that we support H.264.');
|
|
122
|
+
browserSupportedCodecs.push('H264 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42e01f');
|
|
123
|
+
return browserSupportedCodecs;
|
|
124
|
+
}
|
|
125
|
+
const matcher = /(VP\d|H26\d|AV1).*/;
|
|
126
|
+
const codecs = RTCRtpReceiver.getCapabilities('video').codecs;
|
|
127
|
+
codecs.forEach((codec) => {
|
|
128
|
+
const str = codec.mimeType.split('/')[1] + ' ' + (codec.sdpFmtpLine || '');
|
|
129
|
+
const match = matcher.exec(str);
|
|
130
|
+
if (match !== null) {
|
|
131
|
+
browserSupportedCodecs.push(str);
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
return browserSupportedCodecs;
|
|
135
|
+
};
|
|
136
|
+
const getDefaultVideoCodec = function () {
|
|
137
|
+
const videoCodecs = getBrowserSupportedVideoCodecs();
|
|
138
|
+
// If only one option, then select that.
|
|
139
|
+
if (videoCodecs.length == 1) {
|
|
140
|
+
return videoCodecs[0];
|
|
141
|
+
}
|
|
142
|
+
else if (videoCodecs.length > 0) {
|
|
143
|
+
const defaultCodec = videoCodecs[0];
|
|
144
|
+
for (const codec of videoCodecs) {
|
|
145
|
+
if (codec.startsWith('H264')) {
|
|
146
|
+
return codec;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
return defaultCodec;
|
|
150
|
+
}
|
|
151
|
+
lib_pixelstreamingcommon_ue5_5_1.Logger.Error('Could not find any reasonable video codec to assign as a default.');
|
|
152
|
+
return '';
|
|
153
|
+
};
|
|
154
|
+
const matchSpecifiedCodecToClosestSupported = function (specifiedCodec) {
|
|
155
|
+
const browserSupportedCodecs = getBrowserSupportedVideoCodecs();
|
|
156
|
+
// Codec supplied in url param is an exact match for the browser codec.
|
|
157
|
+
// (e.g. H264 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42e01f)
|
|
158
|
+
if (browserSupportedCodecs.includes(specifiedCodec)) {
|
|
159
|
+
return specifiedCodec;
|
|
160
|
+
}
|
|
161
|
+
// Try to match the start of whatever is passed into the url parameter with what the browser supports
|
|
162
|
+
for (const browserCodec of browserSupportedCodecs) {
|
|
163
|
+
if (browserCodec.startsWith(specifiedCodec)) {
|
|
164
|
+
return browserCodec;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
// If we weren't able to match, just return the codec as from the URL as-is.
|
|
168
|
+
return specifiedCodec;
|
|
169
|
+
};
|
|
170
|
+
/**
|
|
171
|
+
* Enum Parameters
|
|
172
|
+
*/
|
|
173
|
+
this.optionParameters.set(OptionParameters.PreferredCodec, new SettingOption_1.SettingOption(OptionParameters.PreferredCodec, 'Preferred Codec', 'The preferred codec to be used during codec negotiation', settings && Object.prototype.hasOwnProperty.call(settings, OptionParameters.PreferredCodec)
|
|
174
|
+
? matchSpecifiedCodecToClosestSupported(settings[OptionParameters.PreferredCodec])
|
|
175
|
+
: getDefaultVideoCodec(), getBrowserSupportedVideoCodecs(), useUrlParams, matchSpecifiedCodecToClosestSupported));
|
|
176
|
+
/**
|
|
177
|
+
* Boolean parameters
|
|
178
|
+
*/
|
|
179
|
+
this.flags.set(Flags.AutoConnect, new SettingFlag_1.SettingFlag(Flags.AutoConnect, 'Auto connect to stream', 'Whether we should attempt to auto connect to the signalling server or show a click to start prompt.', settings && Object.prototype.hasOwnProperty.call(settings, Flags.AutoConnect)
|
|
180
|
+
? settings[Flags.AutoConnect]
|
|
181
|
+
: false, useUrlParams));
|
|
182
|
+
this.flags.set(Flags.AutoPlayVideo, new SettingFlag_1.SettingFlag(Flags.AutoPlayVideo, 'Auto play video', 'When video is ready automatically start playing it as opposed to showing a play button.', settings && Object.prototype.hasOwnProperty.call(settings, Flags.AutoPlayVideo)
|
|
183
|
+
? settings[Flags.AutoPlayVideo]
|
|
184
|
+
: true, useUrlParams));
|
|
185
|
+
this.flags.set(Flags.UseMic, new SettingFlag_1.SettingFlag(Flags.UseMic, 'Use microphone', 'Make browser request microphone access and open an input audio track.', settings && Object.prototype.hasOwnProperty.call(settings, Flags.UseMic)
|
|
186
|
+
? settings[Flags.UseMic]
|
|
187
|
+
: false, useUrlParams));
|
|
188
|
+
this.flags.set(Flags.UseCamera, new SettingFlag_1.SettingFlag(Flags.UseCamera, 'Use webcam', 'Make browser request webcam access and open a input video track.', settings && Object.prototype.hasOwnProperty.call(settings, Flags.UseCamera)
|
|
189
|
+
? settings[Flags.UseCamera]
|
|
190
|
+
: false, useUrlParams));
|
|
191
|
+
this.flags.set(Flags.StartVideoMuted, new SettingFlag_1.SettingFlag(Flags.StartVideoMuted, 'Start video muted', 'Video will start muted if true.', settings && Object.prototype.hasOwnProperty.call(settings, Flags.StartVideoMuted)
|
|
192
|
+
? settings[Flags.StartVideoMuted]
|
|
193
|
+
: false, useUrlParams));
|
|
194
|
+
this.flags.set(Flags.SuppressBrowserKeys, new SettingFlag_1.SettingFlag(Flags.SuppressBrowserKeys, 'Suppress browser keys', 'Suppress certain browser keys that we use in UE, for example F5 to show shader complexity instead of refresh the page.', settings && Object.prototype.hasOwnProperty.call(settings, Flags.SuppressBrowserKeys)
|
|
195
|
+
? settings[Flags.SuppressBrowserKeys]
|
|
196
|
+
: true, useUrlParams));
|
|
197
|
+
this.flags.set(Flags.IsQualityController, new SettingFlag_1.SettingFlag(Flags.IsQualityController, 'Is quality controller?', 'True if this peer controls stream quality', settings && Object.prototype.hasOwnProperty.call(settings, Flags.IsQualityController)
|
|
198
|
+
? settings[Flags.IsQualityController]
|
|
199
|
+
: true, useUrlParams));
|
|
200
|
+
this.flags.set(Flags.ForceMonoAudio, new SettingFlag_1.SettingFlag(Flags.ForceMonoAudio, 'Force mono audio', 'Force browser to request mono audio in the SDP', settings && Object.prototype.hasOwnProperty.call(settings, Flags.ForceMonoAudio)
|
|
201
|
+
? settings[Flags.ForceMonoAudio]
|
|
202
|
+
: false, useUrlParams));
|
|
203
|
+
this.flags.set(Flags.ForceTURN, new SettingFlag_1.SettingFlag(Flags.ForceTURN, 'Force TURN', 'Only generate TURN/Relayed ICE candidates.', settings && Object.prototype.hasOwnProperty.call(settings, Flags.ForceTURN)
|
|
204
|
+
? settings[Flags.ForceTURN]
|
|
205
|
+
: false, useUrlParams));
|
|
206
|
+
this.flags.set(Flags.AFKDetection, new SettingFlag_1.SettingFlag(Flags.AFKDetection, 'AFK if idle', 'Timeout the experience if user is AFK for a period.', settings && Object.prototype.hasOwnProperty.call(settings, Flags.AFKDetection)
|
|
207
|
+
? settings[Flags.AFKDetection]
|
|
208
|
+
: false, useUrlParams));
|
|
209
|
+
this.flags.set(Flags.MatchViewportResolution, new SettingFlag_1.SettingFlag(Flags.MatchViewportResolution, 'Match viewport resolution', 'Pixel Streaming will be instructed to dynamically resize the video stream to match the size of the video element.', settings && Object.prototype.hasOwnProperty.call(settings, Flags.MatchViewportResolution)
|
|
210
|
+
? settings[Flags.MatchViewportResolution]
|
|
211
|
+
: false, useUrlParams));
|
|
212
|
+
this.flags.set(Flags.HoveringMouseMode, new SettingFlag_1.SettingFlag(Flags.HoveringMouseMode, 'Control Scheme: Locked Mouse', 'Either locked mouse, where the pointer is consumed by the video and locked to it, or hovering mouse, where the mouse is not consumed.', settings && Object.prototype.hasOwnProperty.call(settings, Flags.HoveringMouseMode)
|
|
213
|
+
? settings[Flags.HoveringMouseMode]
|
|
214
|
+
: false, useUrlParams, (isHoveringMouse, setting) => {
|
|
215
|
+
setting.label = `Control Scheme: ${isHoveringMouse ? 'Hovering' : 'Locked'} Mouse`;
|
|
216
|
+
}));
|
|
217
|
+
this.flags.set(Flags.FakeMouseWithTouches, new SettingFlag_1.SettingFlag(Flags.FakeMouseWithTouches, 'Fake mouse with touches', 'A single finger touch is converted into a mouse event. This allows a non-touch application to be controlled partially via a touch device.', settings && Object.prototype.hasOwnProperty.call(settings, Flags.FakeMouseWithTouches)
|
|
218
|
+
? settings[Flags.FakeMouseWithTouches]
|
|
219
|
+
: false, useUrlParams));
|
|
220
|
+
this.flags.set(Flags.KeyboardInput, new SettingFlag_1.SettingFlag(Flags.KeyboardInput, 'Keyboard input', 'If enabled, send keyboard events to streamer', settings && Object.prototype.hasOwnProperty.call(settings, Flags.KeyboardInput)
|
|
221
|
+
? settings[Flags.KeyboardInput]
|
|
222
|
+
: true, useUrlParams));
|
|
223
|
+
this.flags.set(Flags.MouseInput, new SettingFlag_1.SettingFlag(Flags.MouseInput, 'Mouse input', 'If enabled, send mouse events to streamer', settings && Object.prototype.hasOwnProperty.call(settings, Flags.MouseInput)
|
|
224
|
+
? settings[Flags.MouseInput]
|
|
225
|
+
: true, useUrlParams));
|
|
226
|
+
this.flags.set(Flags.TouchInput, new SettingFlag_1.SettingFlag(Flags.TouchInput, 'Touch input', 'If enabled, send touch events to streamer', settings && Object.prototype.hasOwnProperty.call(settings, Flags.TouchInput)
|
|
227
|
+
? settings[Flags.TouchInput]
|
|
228
|
+
: true, useUrlParams));
|
|
229
|
+
this.flags.set(Flags.GamepadInput, new SettingFlag_1.SettingFlag(Flags.GamepadInput, 'Gamepad input', 'If enabled, send gamepad events to streamer', settings && Object.prototype.hasOwnProperty.call(settings, Flags.GamepadInput)
|
|
230
|
+
? settings[Flags.GamepadInput]
|
|
231
|
+
: true, useUrlParams));
|
|
232
|
+
this.flags.set(Flags.XRControllerInput, new SettingFlag_1.SettingFlag(Flags.XRControllerInput, 'XR controller input', 'If enabled, send XR controller events to streamer', settings && Object.prototype.hasOwnProperty.call(settings, Flags.XRControllerInput)
|
|
233
|
+
? settings[Flags.XRControllerInput]
|
|
234
|
+
: true, useUrlParams));
|
|
235
|
+
this.flags.set(Flags.WaitForStreamer, new SettingFlag_1.SettingFlag(Flags.WaitForStreamer, 'Wait for streamer', 'Will continue trying to connect to the first streamer available.', settings && Object.prototype.hasOwnProperty.call(settings, Flags.WaitForStreamer)
|
|
236
|
+
? settings[Flags.WaitForStreamer]
|
|
237
|
+
: true, useUrlParams));
|
|
238
|
+
this.flags.set(Flags.HideUI, new SettingFlag_1.SettingFlag(Flags.HideUI, 'Hide the UI overlay', 'Will hide all UI overlay details', settings && Object.prototype.hasOwnProperty.call(settings, Flags.HideUI)
|
|
239
|
+
? settings[Flags.HideUI]
|
|
240
|
+
: false, useUrlParams));
|
|
241
|
+
/**
|
|
242
|
+
* Numeric parameters
|
|
243
|
+
*/
|
|
244
|
+
this.numericParameters.set(NumericParameters.AFKTimeoutSecs, new SettingNumber_1.SettingNumber(NumericParameters.AFKTimeoutSecs, 'AFK timeout', 'The time (in seconds) it takes for the application to time out if AFK timeout is enabled.', 0 /*min*/, null /*max*/, settings && Object.prototype.hasOwnProperty.call(settings, NumericParameters.AFKTimeoutSecs)
|
|
245
|
+
? settings[NumericParameters.AFKTimeoutSecs]
|
|
246
|
+
: 120 /*value*/, useUrlParams));
|
|
247
|
+
this.numericParameters.set(NumericParameters.AFKCountdownSecs, new SettingNumber_1.SettingNumber(NumericParameters.AFKCountdownSecs, 'AFK countdown', 'The time (in seconds) for a user to respond before the stream is ended after an AFK timeout.', 10 /*min*/, null /*max*/, 10 /*value*/, useUrlParams));
|
|
248
|
+
this.numericParameters.set(NumericParameters.MaxReconnectAttempts, new SettingNumber_1.SettingNumber(NumericParameters.MaxReconnectAttempts, 'Max Reconnects', 'Maximum number of reconnects the application will attempt when a streamer disconnects.', 0 /*min*/, 999 /*max*/, settings &&
|
|
249
|
+
Object.prototype.hasOwnProperty.call(settings, NumericParameters.MaxReconnectAttempts)
|
|
250
|
+
? settings[NumericParameters.MaxReconnectAttempts]
|
|
251
|
+
: 3 /*value*/, useUrlParams));
|
|
252
|
+
this.numericParameters.set(NumericParameters.MinQP, new SettingNumber_1.SettingNumber(NumericParameters.MinQP, 'Min QP', 'The lower bound for the quantization parameter (QP) of the encoder. 0 = Best quality, 51 = worst quality.', 0 /*min*/, 51 /*max*/, settings && Object.prototype.hasOwnProperty.call(settings, NumericParameters.MinQP)
|
|
253
|
+
? settings[NumericParameters.MinQP]
|
|
254
|
+
: 0 /*value*/, useUrlParams));
|
|
255
|
+
this.numericParameters.set(NumericParameters.MaxQP, new SettingNumber_1.SettingNumber(NumericParameters.MaxQP, 'Max QP', 'The upper bound for the quantization parameter (QP) of the encoder. 0 = Best quality, 51 = worst quality.', 0 /*min*/, 51 /*max*/, settings && Object.prototype.hasOwnProperty.call(settings, NumericParameters.MaxQP)
|
|
256
|
+
? settings[NumericParameters.MaxQP]
|
|
257
|
+
: 51 /*value*/, useUrlParams));
|
|
258
|
+
this.numericParameters.set(NumericParameters.WebRTCFPS, new SettingNumber_1.SettingNumber(NumericParameters.WebRTCFPS, 'Max FPS', 'The maximum FPS that WebRTC will try to transmit frames at.', 1 /*min*/, 999 /*max*/, settings && Object.prototype.hasOwnProperty.call(settings, NumericParameters.WebRTCFPS)
|
|
259
|
+
? settings[NumericParameters.WebRTCFPS]
|
|
260
|
+
: 60 /*value*/, useUrlParams));
|
|
261
|
+
this.numericParameters.set(NumericParameters.WebRTCMinBitrate, new SettingNumber_1.SettingNumber(NumericParameters.WebRTCMinBitrate, 'Min Bitrate (kbps)', 'The minimum bitrate that WebRTC should use.', 0 /*min*/, 500000 /*max*/, settings && Object.prototype.hasOwnProperty.call(settings, NumericParameters.WebRTCMinBitrate)
|
|
262
|
+
? settings[NumericParameters.WebRTCMinBitrate]
|
|
263
|
+
: 0 /*value*/, useUrlParams));
|
|
264
|
+
this.numericParameters.set(NumericParameters.WebRTCMaxBitrate, new SettingNumber_1.SettingNumber(NumericParameters.WebRTCMaxBitrate, 'Max Bitrate (kbps)', 'The maximum bitrate that WebRTC should use.', 0 /*min*/, 500000 /*max*/, settings && Object.prototype.hasOwnProperty.call(settings, NumericParameters.WebRTCMaxBitrate)
|
|
265
|
+
? settings[NumericParameters.WebRTCMaxBitrate]
|
|
266
|
+
: 0 /*value*/, useUrlParams));
|
|
267
|
+
this.numericParameters.set(NumericParameters.StreamerAutoJoinInterval, new SettingNumber_1.SettingNumber(NumericParameters.StreamerAutoJoinInterval, 'Streamer Auto Join Interval (ms)', 'Delay between retries when waiting for an available streamer.', 500 /*min*/, 900000 /*max*/, settings &&
|
|
268
|
+
Object.prototype.hasOwnProperty.call(settings, NumericParameters.StreamerAutoJoinInterval)
|
|
269
|
+
? settings[NumericParameters.StreamerAutoJoinInterval]
|
|
270
|
+
: 3000 /*value*/, useUrlParams));
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* Add a callback to fire when the numeric setting is toggled.
|
|
274
|
+
* @param id The id of the flag.
|
|
275
|
+
* @param onChangedListener The callback to fire when the numeric value changes.
|
|
276
|
+
*/
|
|
277
|
+
_addOnNumericSettingChangedListener(id, onChangedListener) {
|
|
278
|
+
if (this.numericParameters.has(id)) {
|
|
279
|
+
this.numericParameters.get(id).addOnChangedListener(onChangedListener);
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
_addOnOptionSettingChangedListener(id, onChangedListener) {
|
|
283
|
+
if (this.optionParameters.has(id)) {
|
|
284
|
+
this.optionParameters.get(id).addOnChangedListener(onChangedListener);
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* @param id The id of the numeric setting we are interested in getting a value for.
|
|
289
|
+
* @returns The numeric value stored in the parameter with the passed id.
|
|
290
|
+
*/
|
|
291
|
+
getNumericSettingValue(id) {
|
|
292
|
+
if (this.numericParameters.has(id)) {
|
|
293
|
+
return this.numericParameters.get(id).number;
|
|
294
|
+
}
|
|
295
|
+
else {
|
|
296
|
+
throw new Error(`There is no numeric setting with the id of ${id}`);
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
/**
|
|
300
|
+
* @param id The id of the text setting we are interested in getting a value for.
|
|
301
|
+
* @returns The text value stored in the parameter with the passed id.
|
|
302
|
+
*/
|
|
303
|
+
getTextSettingValue(id) {
|
|
304
|
+
if (this.textParameters.has(id)) {
|
|
305
|
+
return this.textParameters.get(id).value;
|
|
306
|
+
}
|
|
307
|
+
else {
|
|
308
|
+
throw new Error(`There is no numeric setting with the id of ${id}`);
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
/**
|
|
312
|
+
* Set number in the setting.
|
|
313
|
+
* @param id The id of the numeric setting we are interested in.
|
|
314
|
+
* @param value The numeric value to set.
|
|
315
|
+
*/
|
|
316
|
+
setNumericSetting(id, value) {
|
|
317
|
+
if (this.numericParameters.has(id)) {
|
|
318
|
+
this.numericParameters.get(id).number = value;
|
|
319
|
+
}
|
|
320
|
+
else {
|
|
321
|
+
throw new Error(`There is no numeric setting with the id of ${id}`);
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
/**
|
|
325
|
+
* Add a callback to fire when the flag is toggled.
|
|
326
|
+
* @param id The id of the flag.
|
|
327
|
+
* @param onChangeListener The callback to fire when the value changes.
|
|
328
|
+
*/
|
|
329
|
+
_addOnSettingChangedListener(id, onChangeListener) {
|
|
330
|
+
if (this.flags.has(id)) {
|
|
331
|
+
this.flags.get(id).onChange = onChangeListener;
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
/**
|
|
335
|
+
* Add a callback to fire when the text is changed.
|
|
336
|
+
* @param id The id of the flag.
|
|
337
|
+
* @param onChangeListener The callback to fire when the value changes.
|
|
338
|
+
*/
|
|
339
|
+
_addOnTextSettingChangedListener(id, onChangeListener) {
|
|
340
|
+
if (this.textParameters.has(id)) {
|
|
341
|
+
this.textParameters.get(id).onChange = onChangeListener;
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
/**
|
|
345
|
+
* Get the option which has the given id.
|
|
346
|
+
* @param id The id of the option.
|
|
347
|
+
* @returns The SettingOption object matching id
|
|
348
|
+
*/
|
|
349
|
+
getSettingOption(id) {
|
|
350
|
+
return this.optionParameters.get(id);
|
|
351
|
+
}
|
|
352
|
+
/**
|
|
353
|
+
* Get the value of the configuration flag which has the given id.
|
|
354
|
+
* @param id The unique id for the flag.
|
|
355
|
+
* @returns True if the flag is enabled.
|
|
356
|
+
*/
|
|
357
|
+
isFlagEnabled(id) {
|
|
358
|
+
return this.flags.get(id).flag;
|
|
359
|
+
}
|
|
360
|
+
/**
|
|
361
|
+
* Set flag to be enabled/disabled.
|
|
362
|
+
* @param id The id of the flag to toggle.
|
|
363
|
+
* @param flagEnabled True if the flag should be enabled.
|
|
364
|
+
*/
|
|
365
|
+
setFlagEnabled(id, flagEnabled) {
|
|
366
|
+
if (!this.flags.has(id)) {
|
|
367
|
+
lib_pixelstreamingcommon_ue5_5_1.Logger.Warning(`Cannot toggle flag called ${id} - it does not exist in the Config.flags map.`);
|
|
368
|
+
}
|
|
369
|
+
else {
|
|
370
|
+
this.flags.get(id).flag = flagEnabled;
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
/**
|
|
374
|
+
* Set the text setting.
|
|
375
|
+
* @param id The id of the setting
|
|
376
|
+
* @param settingValue The value to set in the setting.
|
|
377
|
+
*/
|
|
378
|
+
setTextSetting(id, settingValue) {
|
|
379
|
+
if (!this.textParameters.has(id)) {
|
|
380
|
+
lib_pixelstreamingcommon_ue5_5_1.Logger.Warning(`Cannot set text setting called ${id} - it does not exist in the Config.textParameters map.`);
|
|
381
|
+
}
|
|
382
|
+
else {
|
|
383
|
+
this.textParameters.get(id).text = settingValue;
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
/**
|
|
387
|
+
* Set the option setting list of options.
|
|
388
|
+
* @param id The id of the setting
|
|
389
|
+
* @param settingOptions The values the setting could take
|
|
390
|
+
*/
|
|
391
|
+
setOptionSettingOptions(id, settingOptions) {
|
|
392
|
+
if (!this.optionParameters.has(id)) {
|
|
393
|
+
lib_pixelstreamingcommon_ue5_5_1.Logger.Warning(`Cannot set text setting called ${id} - it does not exist in the Config.optionParameters map.`);
|
|
394
|
+
}
|
|
395
|
+
else {
|
|
396
|
+
this.optionParameters.get(id).options = settingOptions;
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
/**
|
|
400
|
+
* Set option enum settings selected option.
|
|
401
|
+
* @param id The id of the setting
|
|
402
|
+
* @param settingOptions The value to select out of all the options
|
|
403
|
+
*/
|
|
404
|
+
setOptionSettingValue(id, settingValue) {
|
|
405
|
+
if (!this.optionParameters.has(id)) {
|
|
406
|
+
lib_pixelstreamingcommon_ue5_5_1.Logger.Warning(`Cannot set text setting called ${id} - it does not exist in the Config.enumParameters map.`);
|
|
407
|
+
}
|
|
408
|
+
else {
|
|
409
|
+
const optionSetting = this.optionParameters.get(id);
|
|
410
|
+
const existingOptions = optionSetting.options;
|
|
411
|
+
if (!existingOptions.includes(settingValue)) {
|
|
412
|
+
existingOptions.push(settingValue);
|
|
413
|
+
optionSetting.options = existingOptions;
|
|
414
|
+
}
|
|
415
|
+
optionSetting.selected = settingValue;
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
/**
|
|
419
|
+
* Set the label for the flag.
|
|
420
|
+
* @param id The id of the flag.
|
|
421
|
+
* @param label The new label to use for the flag.
|
|
422
|
+
*/
|
|
423
|
+
setFlagLabel(id, label) {
|
|
424
|
+
if (!this.flags.has(id)) {
|
|
425
|
+
lib_pixelstreamingcommon_ue5_5_1.Logger.Warning(`Cannot set label for flag called ${id} - it does not exist in the Config.flags map.`);
|
|
426
|
+
}
|
|
427
|
+
else {
|
|
428
|
+
this.flags.get(id).label = label;
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
/**
|
|
432
|
+
* Set a subset of all settings in one function call.
|
|
433
|
+
*
|
|
434
|
+
* @param settings A (partial) list of settings to set
|
|
435
|
+
*/
|
|
436
|
+
setSettings(settings) {
|
|
437
|
+
for (const key of Object.keys(settings)) {
|
|
438
|
+
if (isFlagId(key)) {
|
|
439
|
+
this.setFlagEnabled(key, settings[key]);
|
|
440
|
+
}
|
|
441
|
+
else if (isNumericId(key)) {
|
|
442
|
+
this.setNumericSetting(key, settings[key]);
|
|
443
|
+
}
|
|
444
|
+
else if (isTextId(key)) {
|
|
445
|
+
this.setTextSetting(key, settings[key]);
|
|
446
|
+
}
|
|
447
|
+
else if (isOptionId(key)) {
|
|
448
|
+
this.setOptionSettingValue(key, settings[key]);
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
/**
|
|
453
|
+
* Get all settings
|
|
454
|
+
* @returns All setting values as an object with setting ids as keys
|
|
455
|
+
*/
|
|
456
|
+
getSettings() {
|
|
457
|
+
const settings = {};
|
|
458
|
+
for (const [key, value] of this.flags.entries()) {
|
|
459
|
+
settings[key] = value.flag;
|
|
460
|
+
}
|
|
461
|
+
for (const [key, value] of this.numericParameters.entries()) {
|
|
462
|
+
settings[key] = value.number;
|
|
463
|
+
}
|
|
464
|
+
for (const [key, value] of this.textParameters.entries()) {
|
|
465
|
+
settings[key] = value.text;
|
|
466
|
+
}
|
|
467
|
+
for (const [key, value] of this.optionParameters.entries()) {
|
|
468
|
+
settings[key] = value.selected;
|
|
469
|
+
}
|
|
470
|
+
return settings;
|
|
471
|
+
}
|
|
472
|
+
/**
|
|
473
|
+
* Get all Flag settings as an array.
|
|
474
|
+
* @returns All SettingFlag objects
|
|
475
|
+
*/
|
|
476
|
+
getFlags() {
|
|
477
|
+
return Array.from(this.flags.values());
|
|
478
|
+
}
|
|
479
|
+
/**
|
|
480
|
+
* Get all Text settings as an array.
|
|
481
|
+
* @returns All SettingText objects
|
|
482
|
+
*/
|
|
483
|
+
getTextSettings() {
|
|
484
|
+
return Array.from(this.textParameters.values());
|
|
485
|
+
}
|
|
486
|
+
/**
|
|
487
|
+
* Get all Number settings as an array.
|
|
488
|
+
* @returns All SettingNumber objects
|
|
489
|
+
*/
|
|
490
|
+
getNumericSettings() {
|
|
491
|
+
return Array.from(this.numericParameters.values());
|
|
492
|
+
}
|
|
493
|
+
/**
|
|
494
|
+
* Get all Option settings as an array.
|
|
495
|
+
* @returns All SettingOption objects
|
|
496
|
+
*/
|
|
497
|
+
getOptionSettings() {
|
|
498
|
+
return Array.from(this.optionParameters.values());
|
|
499
|
+
}
|
|
500
|
+
/**
|
|
501
|
+
* Emit events when settings change.
|
|
502
|
+
* @param eventEmitter
|
|
503
|
+
*/
|
|
504
|
+
_registerOnChangeEvents(eventEmitter) {
|
|
505
|
+
for (const key of this.flags.keys()) {
|
|
506
|
+
const flag = this.flags.get(key);
|
|
507
|
+
if (flag) {
|
|
508
|
+
flag.onChangeEmit = (newValue) => eventEmitter.dispatchEvent(new EventEmitter_1.SettingsChangedEvent({
|
|
509
|
+
id: flag.id,
|
|
510
|
+
type: 'flag',
|
|
511
|
+
value: newValue,
|
|
512
|
+
target: flag
|
|
513
|
+
}));
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
for (const key of this.numericParameters.keys()) {
|
|
517
|
+
const number = this.numericParameters.get(key);
|
|
518
|
+
if (number) {
|
|
519
|
+
number.onChangeEmit = (newValue) => eventEmitter.dispatchEvent(new EventEmitter_1.SettingsChangedEvent({
|
|
520
|
+
id: number.id,
|
|
521
|
+
type: 'number',
|
|
522
|
+
value: newValue,
|
|
523
|
+
target: number
|
|
524
|
+
}));
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
for (const key of this.textParameters.keys()) {
|
|
528
|
+
const text = this.textParameters.get(key);
|
|
529
|
+
if (text) {
|
|
530
|
+
text.onChangeEmit = (newValue) => eventEmitter.dispatchEvent(new EventEmitter_1.SettingsChangedEvent({
|
|
531
|
+
id: text.id,
|
|
532
|
+
type: 'text',
|
|
533
|
+
value: newValue,
|
|
534
|
+
target: text
|
|
535
|
+
}));
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
for (const key of this.optionParameters.keys()) {
|
|
539
|
+
const option = this.optionParameters.get(key);
|
|
540
|
+
if (option) {
|
|
541
|
+
option.onChangeEmit = (newValue) => eventEmitter.dispatchEvent(new EventEmitter_1.SettingsChangedEvent({
|
|
542
|
+
id: option.id,
|
|
543
|
+
type: 'option',
|
|
544
|
+
value: newValue,
|
|
545
|
+
target: option
|
|
546
|
+
}));
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
exports.Config = Config;
|
|
552
|
+
/**
|
|
553
|
+
* The enum associated with the mouse being locked or hovering
|
|
554
|
+
*/
|
|
555
|
+
var ControlSchemeType;
|
|
556
|
+
(function (ControlSchemeType) {
|
|
557
|
+
ControlSchemeType[ControlSchemeType["LockedMouse"] = 0] = "LockedMouse";
|
|
558
|
+
ControlSchemeType[ControlSchemeType["HoveringMouse"] = 1] = "HoveringMouse";
|
|
559
|
+
})(ControlSchemeType = exports.ControlSchemeType || (exports.ControlSchemeType = {}));
|
|
560
560
|
//# sourceMappingURL=Config.js.map
|