@epicgames-ps/lib-pixelstreamingfrontend-ue5.5 0.3.0 → 0.3.1
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/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/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
|
@@ -1,104 +1,104 @@
|
|
|
1
|
-
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
2
|
-
import { Logger } from '@epicgames-ps/lib-pixelstreamingcommon-ue5.5';
|
|
3
|
-
/**
|
|
4
|
-
* Utility function for populate file information from byte buffers.
|
|
5
|
-
*/
|
|
6
|
-
export class FileUtil {
|
|
7
|
-
/**
|
|
8
|
-
* Processes a files extension when received over data channel
|
|
9
|
-
* @param view - the file extension data
|
|
10
|
-
*/
|
|
11
|
-
static setExtensionFromBytes(view, file) {
|
|
12
|
-
// Reset file if we got a file message and we are not "receiving" it yet
|
|
13
|
-
if (!file.receiving) {
|
|
14
|
-
file.mimetype = '';
|
|
15
|
-
file.extension = '';
|
|
16
|
-
file.receiving = true;
|
|
17
|
-
file.valid = false;
|
|
18
|
-
file.size = 0;
|
|
19
|
-
file.data = [];
|
|
20
|
-
file.timestampStart = new Date().getTime();
|
|
21
|
-
Logger.Info('Received first chunk of file');
|
|
22
|
-
}
|
|
23
|
-
const extensionAsString = new TextDecoder('utf-16').decode(view.slice(1));
|
|
24
|
-
Logger.Info(extensionAsString);
|
|
25
|
-
file.extension = extensionAsString;
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Processes a files mime type when received over data channel
|
|
29
|
-
* @param view - the file mime type data
|
|
30
|
-
*/
|
|
31
|
-
static setMimeTypeFromBytes(view, file) {
|
|
32
|
-
// Reset file if we got a file message and we are not "receiving" it yet
|
|
33
|
-
if (!file.receiving) {
|
|
34
|
-
file.mimetype = '';
|
|
35
|
-
file.extension = '';
|
|
36
|
-
file.receiving = true;
|
|
37
|
-
file.valid = false;
|
|
38
|
-
file.size = 0;
|
|
39
|
-
file.data = [];
|
|
40
|
-
file.timestampStart = new Date().getTime();
|
|
41
|
-
Logger.Info('Received first chunk of file');
|
|
42
|
-
}
|
|
43
|
-
const mimeAsString = new TextDecoder('utf-16').decode(view.slice(1));
|
|
44
|
-
Logger.Info(mimeAsString);
|
|
45
|
-
file.mimetype = mimeAsString;
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Processes a files contents when received over data channel
|
|
49
|
-
* @param view - the file contents data
|
|
50
|
-
*/
|
|
51
|
-
static setContentsFromBytes(view, file) {
|
|
52
|
-
// If we haven't received the initial setup instructions, return
|
|
53
|
-
if (!file.receiving)
|
|
54
|
-
return;
|
|
55
|
-
// Extract the total size of the file (across all chunks)
|
|
56
|
-
file.size = Math.ceil(new DataView(view.slice(1, 5).buffer).getInt32(0, true) /
|
|
57
|
-
16379 /* The maximum number of payload bits per message*/);
|
|
58
|
-
// Get the file part of the payload
|
|
59
|
-
const fileBytes = view.slice(1 + 4);
|
|
60
|
-
// Append to existing data that holds the file
|
|
61
|
-
file.data.push(fileBytes);
|
|
62
|
-
// Uncomment for debug
|
|
63
|
-
Logger.Info(`Received file chunk: ${file.data.length}/${file.size}`);
|
|
64
|
-
if (file.data.length === file.size) {
|
|
65
|
-
file.receiving = false;
|
|
66
|
-
file.valid = true;
|
|
67
|
-
Logger.Info('Received complete file');
|
|
68
|
-
const transferDuration = new Date().getTime() - file.timestampStart;
|
|
69
|
-
const transferBitrate = Math.round((file.size * 16 * 1024) / transferDuration);
|
|
70
|
-
Logger.Info(`Average transfer bitrate: ${transferBitrate}kb/s over ${transferDuration / 1000} seconds`);
|
|
71
|
-
// File reconstruction
|
|
72
|
-
/**
|
|
73
|
-
* Example code to reconstruct the file
|
|
74
|
-
*
|
|
75
|
-
* This code reconstructs the received data into the original file based on the mime type and extension provided and then downloads the reconstructed file
|
|
76
|
-
*/
|
|
77
|
-
const received = new Blob(file.data, { type: file.mimetype });
|
|
78
|
-
const a = document.createElement('a');
|
|
79
|
-
a.setAttribute('href', URL.createObjectURL(received));
|
|
80
|
-
a.setAttribute('download', `transfer.${file.extension}`);
|
|
81
|
-
document.body.append(a);
|
|
82
|
-
// if you are so inclined to make it auto-download, do something like: a.click();
|
|
83
|
-
a.remove();
|
|
84
|
-
}
|
|
85
|
-
else if (file.data.length > file.size) {
|
|
86
|
-
file.receiving = false;
|
|
87
|
-
Logger.Error(`Received bigger file than advertised: ${file.data.length}/${file.size}`);
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
/**
|
|
92
|
-
* A class that represents a template for a downloaded file
|
|
93
|
-
*/
|
|
94
|
-
export class FileTemplate {
|
|
95
|
-
constructor() {
|
|
96
|
-
this.mimetype = '';
|
|
97
|
-
this.extension = '';
|
|
98
|
-
this.receiving = false;
|
|
99
|
-
this.size = 0;
|
|
100
|
-
this.data = [];
|
|
101
|
-
this.valid = false;
|
|
102
|
-
}
|
|
103
|
-
}
|
|
1
|
+
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
2
|
+
import { Logger } from '@epicgames-ps/lib-pixelstreamingcommon-ue5.5';
|
|
3
|
+
/**
|
|
4
|
+
* Utility function for populate file information from byte buffers.
|
|
5
|
+
*/
|
|
6
|
+
export class FileUtil {
|
|
7
|
+
/**
|
|
8
|
+
* Processes a files extension when received over data channel
|
|
9
|
+
* @param view - the file extension data
|
|
10
|
+
*/
|
|
11
|
+
static setExtensionFromBytes(view, file) {
|
|
12
|
+
// Reset file if we got a file message and we are not "receiving" it yet
|
|
13
|
+
if (!file.receiving) {
|
|
14
|
+
file.mimetype = '';
|
|
15
|
+
file.extension = '';
|
|
16
|
+
file.receiving = true;
|
|
17
|
+
file.valid = false;
|
|
18
|
+
file.size = 0;
|
|
19
|
+
file.data = [];
|
|
20
|
+
file.timestampStart = new Date().getTime();
|
|
21
|
+
Logger.Info('Received first chunk of file');
|
|
22
|
+
}
|
|
23
|
+
const extensionAsString = new TextDecoder('utf-16').decode(view.slice(1));
|
|
24
|
+
Logger.Info(extensionAsString);
|
|
25
|
+
file.extension = extensionAsString;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Processes a files mime type when received over data channel
|
|
29
|
+
* @param view - the file mime type data
|
|
30
|
+
*/
|
|
31
|
+
static setMimeTypeFromBytes(view, file) {
|
|
32
|
+
// Reset file if we got a file message and we are not "receiving" it yet
|
|
33
|
+
if (!file.receiving) {
|
|
34
|
+
file.mimetype = '';
|
|
35
|
+
file.extension = '';
|
|
36
|
+
file.receiving = true;
|
|
37
|
+
file.valid = false;
|
|
38
|
+
file.size = 0;
|
|
39
|
+
file.data = [];
|
|
40
|
+
file.timestampStart = new Date().getTime();
|
|
41
|
+
Logger.Info('Received first chunk of file');
|
|
42
|
+
}
|
|
43
|
+
const mimeAsString = new TextDecoder('utf-16').decode(view.slice(1));
|
|
44
|
+
Logger.Info(mimeAsString);
|
|
45
|
+
file.mimetype = mimeAsString;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Processes a files contents when received over data channel
|
|
49
|
+
* @param view - the file contents data
|
|
50
|
+
*/
|
|
51
|
+
static setContentsFromBytes(view, file) {
|
|
52
|
+
// If we haven't received the initial setup instructions, return
|
|
53
|
+
if (!file.receiving)
|
|
54
|
+
return;
|
|
55
|
+
// Extract the total size of the file (across all chunks)
|
|
56
|
+
file.size = Math.ceil(new DataView(view.slice(1, 5).buffer).getInt32(0, true) /
|
|
57
|
+
16379 /* The maximum number of payload bits per message*/);
|
|
58
|
+
// Get the file part of the payload
|
|
59
|
+
const fileBytes = view.slice(1 + 4);
|
|
60
|
+
// Append to existing data that holds the file
|
|
61
|
+
file.data.push(fileBytes);
|
|
62
|
+
// Uncomment for debug
|
|
63
|
+
Logger.Info(`Received file chunk: ${file.data.length}/${file.size}`);
|
|
64
|
+
if (file.data.length === file.size) {
|
|
65
|
+
file.receiving = false;
|
|
66
|
+
file.valid = true;
|
|
67
|
+
Logger.Info('Received complete file');
|
|
68
|
+
const transferDuration = new Date().getTime() - file.timestampStart;
|
|
69
|
+
const transferBitrate = Math.round((file.size * 16 * 1024) / transferDuration);
|
|
70
|
+
Logger.Info(`Average transfer bitrate: ${transferBitrate}kb/s over ${transferDuration / 1000} seconds`);
|
|
71
|
+
// File reconstruction
|
|
72
|
+
/**
|
|
73
|
+
* Example code to reconstruct the file
|
|
74
|
+
*
|
|
75
|
+
* This code reconstructs the received data into the original file based on the mime type and extension provided and then downloads the reconstructed file
|
|
76
|
+
*/
|
|
77
|
+
const received = new Blob(file.data, { type: file.mimetype });
|
|
78
|
+
const a = document.createElement('a');
|
|
79
|
+
a.setAttribute('href', URL.createObjectURL(received));
|
|
80
|
+
a.setAttribute('download', `transfer.${file.extension}`);
|
|
81
|
+
document.body.append(a);
|
|
82
|
+
// if you are so inclined to make it auto-download, do something like: a.click();
|
|
83
|
+
a.remove();
|
|
84
|
+
}
|
|
85
|
+
else if (file.data.length > file.size) {
|
|
86
|
+
file.receiving = false;
|
|
87
|
+
Logger.Error(`Received bigger file than advertised: ${file.data.length}/${file.size}`);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* A class that represents a template for a downloaded file
|
|
93
|
+
*/
|
|
94
|
+
export class FileTemplate {
|
|
95
|
+
constructor() {
|
|
96
|
+
this.mimetype = '';
|
|
97
|
+
this.extension = '';
|
|
98
|
+
this.receiving = false;
|
|
99
|
+
this.size = 0;
|
|
100
|
+
this.data = [];
|
|
101
|
+
this.valid = false;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
104
|
//# sourceMappingURL=FileUtil.js.map
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A case insensitive, partial implementation of URLSearchParams
|
|
3
|
-
*/
|
|
4
|
-
export class IURLSearchParams {
|
|
5
|
-
constructor(search) {
|
|
6
|
-
this._urlParams = {};
|
|
7
|
-
const urlParams = new URLSearchParams(search);
|
|
8
|
-
for (const [name, value] of urlParams) {
|
|
9
|
-
this._urlParams[name.toLowerCase()] = value;
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
has(name) {
|
|
13
|
-
return name.toLowerCase() in this._urlParams;
|
|
14
|
-
}
|
|
15
|
-
get(name) {
|
|
16
|
-
if (this.has(name)) {
|
|
17
|
-
return this._urlParams[name.toLowerCase()];
|
|
18
|
-
}
|
|
19
|
-
return null;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* A case insensitive, partial implementation of URLSearchParams
|
|
3
|
+
*/
|
|
4
|
+
export class IURLSearchParams {
|
|
5
|
+
constructor(search) {
|
|
6
|
+
this._urlParams = {};
|
|
7
|
+
const urlParams = new URLSearchParams(search);
|
|
8
|
+
for (const [name, value] of urlParams) {
|
|
9
|
+
this._urlParams[name.toLowerCase()] = value;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
has(name) {
|
|
13
|
+
return name.toLowerCase() in this._urlParams;
|
|
14
|
+
}
|
|
15
|
+
get(name) {
|
|
16
|
+
if (this.has(name)) {
|
|
17
|
+
return this._urlParams[name.toLowerCase()];
|
|
18
|
+
}
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
22
|
//# sourceMappingURL=IURLSearchParams.js.map
|
|
@@ -1,46 +1,46 @@
|
|
|
1
|
-
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
2
|
-
/**
|
|
3
|
-
* Converts coordinates from element relative coordinates to values normalized within the value range of a short (and back again)
|
|
4
|
-
*/
|
|
5
|
-
export class InputCoordTranslator {
|
|
6
|
-
// we dont use a constructor here because the object is created and passed around to various locations
|
|
7
|
-
// possibly before this method is called.
|
|
8
|
-
reconfigure(playerSize, videoSize) {
|
|
9
|
-
const playerAspectRatio = playerSize.height / playerSize.width;
|
|
10
|
-
const videoAspectRatio = videoSize.height / videoSize.width;
|
|
11
|
-
this.playerIsLarger = playerAspectRatio > videoAspectRatio;
|
|
12
|
-
this.playerSize = playerSize;
|
|
13
|
-
this.ratio = this.playerIsLarger
|
|
14
|
-
? playerAspectRatio / videoAspectRatio
|
|
15
|
-
: videoAspectRatio / playerAspectRatio;
|
|
16
|
-
}
|
|
17
|
-
translateUnsigned(x, y) {
|
|
18
|
-
const normalizedX = this.playerIsLarger
|
|
19
|
-
? x / this.playerSize.width
|
|
20
|
-
: this.ratio * (x / this.playerSize.width - 0.5) + 0.5;
|
|
21
|
-
const normalizedY = this.playerIsLarger
|
|
22
|
-
? this.ratio * (y / this.playerSize.height - 0.5) + 0.5
|
|
23
|
-
: y / this.playerSize.height;
|
|
24
|
-
if (normalizedX < 0.0 || normalizedX > 1.0 || normalizedY < 0.0 || normalizedY > 1.0) {
|
|
25
|
-
return { inRange: false, x: 65535, y: 65535 };
|
|
26
|
-
}
|
|
27
|
-
else {
|
|
28
|
-
return { inRange: true, x: normalizedX * 65536, y: normalizedY * 65536 };
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
translateSigned(x, y) {
|
|
32
|
-
const normalizedX = this.playerIsLarger
|
|
33
|
-
? x / (0.5 * this.playerSize.width)
|
|
34
|
-
: (this.ratio * x) / (0.5 * this.playerSize.width);
|
|
35
|
-
const normalizedY = this.playerIsLarger
|
|
36
|
-
? (this.ratio * y) / (0.5 * this.playerSize.height)
|
|
37
|
-
: y / (0.5 * this.playerSize.height);
|
|
38
|
-
return { x: normalizedX * 32767, y: normalizedY * 32767 };
|
|
39
|
-
}
|
|
40
|
-
untranslateUnsigned(x, y) {
|
|
41
|
-
const normalizedX = this.playerIsLarger ? x / 65536 : (x / 65536 - 0.5) / this.ratio + 0.5;
|
|
42
|
-
const normalizedY = this.playerIsLarger ? (y / 65536 - 0.5) / this.ratio + 0.5 : y / 65536;
|
|
43
|
-
return { x: normalizedX * this.playerSize.width, y: normalizedY * this.playerSize.height };
|
|
44
|
-
}
|
|
45
|
-
}
|
|
1
|
+
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
2
|
+
/**
|
|
3
|
+
* Converts coordinates from element relative coordinates to values normalized within the value range of a short (and back again)
|
|
4
|
+
*/
|
|
5
|
+
export class InputCoordTranslator {
|
|
6
|
+
// we dont use a constructor here because the object is created and passed around to various locations
|
|
7
|
+
// possibly before this method is called.
|
|
8
|
+
reconfigure(playerSize, videoSize) {
|
|
9
|
+
const playerAspectRatio = playerSize.height / playerSize.width;
|
|
10
|
+
const videoAspectRatio = videoSize.height / videoSize.width;
|
|
11
|
+
this.playerIsLarger = playerAspectRatio > videoAspectRatio;
|
|
12
|
+
this.playerSize = playerSize;
|
|
13
|
+
this.ratio = this.playerIsLarger
|
|
14
|
+
? playerAspectRatio / videoAspectRatio
|
|
15
|
+
: videoAspectRatio / playerAspectRatio;
|
|
16
|
+
}
|
|
17
|
+
translateUnsigned(x, y) {
|
|
18
|
+
const normalizedX = this.playerIsLarger
|
|
19
|
+
? x / this.playerSize.width
|
|
20
|
+
: this.ratio * (x / this.playerSize.width - 0.5) + 0.5;
|
|
21
|
+
const normalizedY = this.playerIsLarger
|
|
22
|
+
? this.ratio * (y / this.playerSize.height - 0.5) + 0.5
|
|
23
|
+
: y / this.playerSize.height;
|
|
24
|
+
if (normalizedX < 0.0 || normalizedX > 1.0 || normalizedY < 0.0 || normalizedY > 1.0) {
|
|
25
|
+
return { inRange: false, x: 65535, y: 65535 };
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
return { inRange: true, x: normalizedX * 65536, y: normalizedY * 65536 };
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
translateSigned(x, y) {
|
|
32
|
+
const normalizedX = this.playerIsLarger
|
|
33
|
+
? x / (0.5 * this.playerSize.width)
|
|
34
|
+
: (this.ratio * x) / (0.5 * this.playerSize.width);
|
|
35
|
+
const normalizedY = this.playerIsLarger
|
|
36
|
+
? (this.ratio * y) / (0.5 * this.playerSize.height)
|
|
37
|
+
: y / (0.5 * this.playerSize.height);
|
|
38
|
+
return { x: normalizedX * 32767, y: normalizedY * 32767 };
|
|
39
|
+
}
|
|
40
|
+
untranslateUnsigned(x, y) {
|
|
41
|
+
const normalizedX = this.playerIsLarger ? x / 65536 : (x / 65536 - 0.5) / this.ratio + 0.5;
|
|
42
|
+
const normalizedY = this.playerIsLarger ? (y / 65536 - 0.5) / this.ratio + 0.5 : y / 65536;
|
|
43
|
+
return { x: normalizedX * this.playerSize.width, y: normalizedY * this.playerSize.height };
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
46
|
//# sourceMappingURL=InputCoordTranslator.js.map
|
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
export class RTCUtils {
|
|
2
|
-
static isVideoTransceiver(transceiver) {
|
|
3
|
-
return this.canTransceiverReceiveVideo(transceiver) || this.canTransceiverSendVideo(transceiver);
|
|
4
|
-
}
|
|
5
|
-
static canTransceiverReceiveVideo(transceiver) {
|
|
6
|
-
return (!!transceiver &&
|
|
7
|
-
(transceiver.direction === 'sendrecv' || transceiver.direction === 'recvonly') &&
|
|
8
|
-
transceiver.receiver &&
|
|
9
|
-
transceiver.receiver.track &&
|
|
10
|
-
transceiver.receiver.track.kind === 'video');
|
|
11
|
-
}
|
|
12
|
-
static canTransceiverSendVideo(transceiver) {
|
|
13
|
-
return (!!transceiver &&
|
|
14
|
-
(transceiver.direction === 'sendrecv' || transceiver.direction === 'sendonly') &&
|
|
15
|
-
transceiver.sender &&
|
|
16
|
-
transceiver.sender.track &&
|
|
17
|
-
transceiver.sender.track.kind === 'video');
|
|
18
|
-
}
|
|
19
|
-
static isAudioTransceiver(transceiver) {
|
|
20
|
-
return this.canTransceiverReceiveAudio(transceiver) || this.canTransceiverSendAudio(transceiver);
|
|
21
|
-
}
|
|
22
|
-
static canTransceiverReceiveAudio(transceiver) {
|
|
23
|
-
return (!!transceiver &&
|
|
24
|
-
(transceiver.direction === 'sendrecv' || transceiver.direction === 'recvonly') &&
|
|
25
|
-
transceiver.receiver &&
|
|
26
|
-
transceiver.receiver.track &&
|
|
27
|
-
transceiver.receiver.track.kind === 'audio');
|
|
28
|
-
}
|
|
29
|
-
static canTransceiverSendAudio(transceiver) {
|
|
30
|
-
return (!!transceiver &&
|
|
31
|
-
(transceiver.direction === 'sendrecv' || transceiver.direction === 'sendonly') &&
|
|
32
|
-
transceiver.sender &&
|
|
33
|
-
transceiver.sender.track &&
|
|
34
|
-
transceiver.sender.track.kind === 'audio');
|
|
35
|
-
}
|
|
36
|
-
}
|
|
1
|
+
export class RTCUtils {
|
|
2
|
+
static isVideoTransceiver(transceiver) {
|
|
3
|
+
return this.canTransceiverReceiveVideo(transceiver) || this.canTransceiverSendVideo(transceiver);
|
|
4
|
+
}
|
|
5
|
+
static canTransceiverReceiveVideo(transceiver) {
|
|
6
|
+
return (!!transceiver &&
|
|
7
|
+
(transceiver.direction === 'sendrecv' || transceiver.direction === 'recvonly') &&
|
|
8
|
+
transceiver.receiver &&
|
|
9
|
+
transceiver.receiver.track &&
|
|
10
|
+
transceiver.receiver.track.kind === 'video');
|
|
11
|
+
}
|
|
12
|
+
static canTransceiverSendVideo(transceiver) {
|
|
13
|
+
return (!!transceiver &&
|
|
14
|
+
(transceiver.direction === 'sendrecv' || transceiver.direction === 'sendonly') &&
|
|
15
|
+
transceiver.sender &&
|
|
16
|
+
transceiver.sender.track &&
|
|
17
|
+
transceiver.sender.track.kind === 'video');
|
|
18
|
+
}
|
|
19
|
+
static isAudioTransceiver(transceiver) {
|
|
20
|
+
return this.canTransceiverReceiveAudio(transceiver) || this.canTransceiverSendAudio(transceiver);
|
|
21
|
+
}
|
|
22
|
+
static canTransceiverReceiveAudio(transceiver) {
|
|
23
|
+
return (!!transceiver &&
|
|
24
|
+
(transceiver.direction === 'sendrecv' || transceiver.direction === 'recvonly') &&
|
|
25
|
+
transceiver.receiver &&
|
|
26
|
+
transceiver.receiver.track &&
|
|
27
|
+
transceiver.receiver.track.kind === 'audio');
|
|
28
|
+
}
|
|
29
|
+
static canTransceiverSendAudio(transceiver) {
|
|
30
|
+
return (!!transceiver &&
|
|
31
|
+
(transceiver.direction === 'sendrecv' || transceiver.direction === 'sendonly') &&
|
|
32
|
+
transceiver.sender &&
|
|
33
|
+
transceiver.sender.track &&
|
|
34
|
+
transceiver.sender.track.kind === 'audio');
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
37
|
//# sourceMappingURL=RTCUtils.js.map
|
|
@@ -1,64 +1,64 @@
|
|
|
1
|
-
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
2
|
-
import { Logger } from '@epicgames-ps/lib-pixelstreamingcommon-ue5.5';
|
|
3
|
-
/**
|
|
4
|
-
* Video Player Controller handles the creation of the video HTML element and all handlers
|
|
5
|
-
*/
|
|
6
|
-
export class StreamController {
|
|
7
|
-
/**
|
|
8
|
-
* @param videoElementProvider Video Player instance
|
|
9
|
-
*/
|
|
10
|
-
constructor(videoElementProvider) {
|
|
11
|
-
this.videoElementProvider = videoElementProvider;
|
|
12
|
-
this.audioElement = document.createElement('Audio');
|
|
13
|
-
this.videoElementProvider.setAudioElement(this.audioElement);
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Handles when the Peer connection has a track event
|
|
17
|
-
* @param rtcTrackEvent - RTC Track Event
|
|
18
|
-
*/
|
|
19
|
-
handleOnTrack(rtcTrackEvent) {
|
|
20
|
-
Logger.Info('handleOnTrack ' + JSON.stringify(rtcTrackEvent.streams));
|
|
21
|
-
// Do not add the track if the ID is `probator` as this is special track created by mediasoup for bitrate probing.
|
|
22
|
-
// Refer to https://github.com/EpicGamesExt/PixelStreamingInfrastructure/pull/86 for more details.
|
|
23
|
-
if (rtcTrackEvent.streams.length < 1 || rtcTrackEvent.streams[0].id == 'probator') {
|
|
24
|
-
return;
|
|
25
|
-
}
|
|
26
|
-
const videoElement = this.videoElementProvider.getVideoElement();
|
|
27
|
-
if (rtcTrackEvent.track) {
|
|
28
|
-
Logger.Info('Got track - ' +
|
|
29
|
-
rtcTrackEvent.track.kind +
|
|
30
|
-
' id=' +
|
|
31
|
-
rtcTrackEvent.track.id +
|
|
32
|
-
' readyState=' +
|
|
33
|
-
rtcTrackEvent.track.readyState);
|
|
34
|
-
}
|
|
35
|
-
if (rtcTrackEvent.track.kind == 'audio') {
|
|
36
|
-
this.CreateAudioTrack(rtcTrackEvent.streams[0]);
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
else if (rtcTrackEvent.track.kind == 'video' &&
|
|
40
|
-
videoElement.srcObject !== rtcTrackEvent.streams[0]) {
|
|
41
|
-
videoElement.srcObject = rtcTrackEvent.streams[0];
|
|
42
|
-
Logger.Info('Set video source from video track ontrack.');
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Creates the audio device when receiving an RTCTrackEvent with the kind of "audio"
|
|
48
|
-
* @param audioMediaStream - Audio Media stream track
|
|
49
|
-
*/
|
|
50
|
-
CreateAudioTrack(audioMediaStream) {
|
|
51
|
-
const videoElement = this.videoElementProvider.getVideoElement();
|
|
52
|
-
// do nothing the video has the same media stream as the audio track we have here (they are linked)
|
|
53
|
-
if (videoElement.srcObject == audioMediaStream) {
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
56
|
-
// video element has some other media stream that is not associated with this audio track
|
|
57
|
-
else if (videoElement.srcObject && videoElement.srcObject !== audioMediaStream) {
|
|
58
|
-
// create a new audio element
|
|
59
|
-
this.audioElement.srcObject = audioMediaStream;
|
|
60
|
-
Logger.Info('Created new audio element to play separate audio stream.');
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}
|
|
1
|
+
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
2
|
+
import { Logger } from '@epicgames-ps/lib-pixelstreamingcommon-ue5.5';
|
|
3
|
+
/**
|
|
4
|
+
* Video Player Controller handles the creation of the video HTML element and all handlers
|
|
5
|
+
*/
|
|
6
|
+
export class StreamController {
|
|
7
|
+
/**
|
|
8
|
+
* @param videoElementProvider Video Player instance
|
|
9
|
+
*/
|
|
10
|
+
constructor(videoElementProvider) {
|
|
11
|
+
this.videoElementProvider = videoElementProvider;
|
|
12
|
+
this.audioElement = document.createElement('Audio');
|
|
13
|
+
this.videoElementProvider.setAudioElement(this.audioElement);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Handles when the Peer connection has a track event
|
|
17
|
+
* @param rtcTrackEvent - RTC Track Event
|
|
18
|
+
*/
|
|
19
|
+
handleOnTrack(rtcTrackEvent) {
|
|
20
|
+
Logger.Info('handleOnTrack ' + JSON.stringify(rtcTrackEvent.streams));
|
|
21
|
+
// Do not add the track if the ID is `probator` as this is special track created by mediasoup for bitrate probing.
|
|
22
|
+
// Refer to https://github.com/EpicGamesExt/PixelStreamingInfrastructure/pull/86 for more details.
|
|
23
|
+
if (rtcTrackEvent.streams.length < 1 || rtcTrackEvent.streams[0].id == 'probator') {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
const videoElement = this.videoElementProvider.getVideoElement();
|
|
27
|
+
if (rtcTrackEvent.track) {
|
|
28
|
+
Logger.Info('Got track - ' +
|
|
29
|
+
rtcTrackEvent.track.kind +
|
|
30
|
+
' id=' +
|
|
31
|
+
rtcTrackEvent.track.id +
|
|
32
|
+
' readyState=' +
|
|
33
|
+
rtcTrackEvent.track.readyState);
|
|
34
|
+
}
|
|
35
|
+
if (rtcTrackEvent.track.kind == 'audio') {
|
|
36
|
+
this.CreateAudioTrack(rtcTrackEvent.streams[0]);
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
else if (rtcTrackEvent.track.kind == 'video' &&
|
|
40
|
+
videoElement.srcObject !== rtcTrackEvent.streams[0]) {
|
|
41
|
+
videoElement.srcObject = rtcTrackEvent.streams[0];
|
|
42
|
+
Logger.Info('Set video source from video track ontrack.');
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Creates the audio device when receiving an RTCTrackEvent with the kind of "audio"
|
|
48
|
+
* @param audioMediaStream - Audio Media stream track
|
|
49
|
+
*/
|
|
50
|
+
CreateAudioTrack(audioMediaStream) {
|
|
51
|
+
const videoElement = this.videoElementProvider.getVideoElement();
|
|
52
|
+
// do nothing the video has the same media stream as the audio track we have here (they are linked)
|
|
53
|
+
if (videoElement.srcObject == audioMediaStream) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
// video element has some other media stream that is not associated with this audio track
|
|
57
|
+
else if (videoElement.srcObject && videoElement.srcObject !== audioMediaStream) {
|
|
58
|
+
// create a new audio element
|
|
59
|
+
this.audioElement.srcObject = audioMediaStream;
|
|
60
|
+
Logger.Info('Created new audio element to play separate audio stream.');
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
64
|
//# sourceMappingURL=StreamController.js.map
|