@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,57 +1,57 @@
|
|
|
1
|
-
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
2
|
-
import { Logger } from '@epicgames-ps/lib-pixelstreamingcommon-ue5.5';
|
|
3
|
-
/**
|
|
4
|
-
* Latency Test Results Data
|
|
5
|
-
*/
|
|
6
|
-
export class LatencyTestResults {
|
|
7
|
-
constructor() {
|
|
8
|
-
//Fields Set from the latency payload regardless of version
|
|
9
|
-
this.ReceiptTimeMs = null;
|
|
10
|
-
this.TransmissionTimeMs = null;
|
|
11
|
-
//Fields Set from the latency payload from 4.27.2
|
|
12
|
-
this.PreCaptureTimeMs = null;
|
|
13
|
-
this.PostCaptureTimeMs = null;
|
|
14
|
-
this.PreEncodeTimeMs = null;
|
|
15
|
-
this.PostEncodeTimeMs = null;
|
|
16
|
-
//Fields Set from the latency payload from 5.0
|
|
17
|
-
this.EncodeMs = null;
|
|
18
|
-
this.CaptureToSendMs = null;
|
|
19
|
-
//Fields Set when processed
|
|
20
|
-
this.testStartTimeMs = 0;
|
|
21
|
-
this.browserReceiptTimeMs = 0;
|
|
22
|
-
//Fields set from calculations
|
|
23
|
-
this.latencyExcludingDecode = 0;
|
|
24
|
-
this.testDuration = 0;
|
|
25
|
-
//ueLatency: number = 0;
|
|
26
|
-
this.networkLatency = 0;
|
|
27
|
-
this.browserSendLatency = 0;
|
|
28
|
-
this.frameDisplayDeltaTimeMs = 0;
|
|
29
|
-
this.endToEndLatency = 0;
|
|
30
|
-
//uePixelStreamLatency: number = 0;
|
|
31
|
-
this.encodeLatency = 0;
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Sets the Delta Time Milliseconds
|
|
35
|
-
* @param DeltaTimeMs - Delta Time Milliseconds
|
|
36
|
-
*/
|
|
37
|
-
setFrameDisplayDeltaTime(DeltaTimeMs) {
|
|
38
|
-
if (this.frameDisplayDeltaTimeMs == 0) {
|
|
39
|
-
this.frameDisplayDeltaTimeMs = Math.round(DeltaTimeMs);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Process the encoder times and set them
|
|
44
|
-
*/
|
|
45
|
-
processFields() {
|
|
46
|
-
if (this.EncodeMs == null && (this.PreEncodeTimeMs != null || this.PostEncodeTimeMs != null)) {
|
|
47
|
-
Logger.Info(`Setting Encode Ms \n ${this.PostEncodeTimeMs} \n ${this.PreEncodeTimeMs}`);
|
|
48
|
-
this.EncodeMs = this.PostEncodeTimeMs - this.PreEncodeTimeMs;
|
|
49
|
-
}
|
|
50
|
-
if (this.CaptureToSendMs == null &&
|
|
51
|
-
(this.PreCaptureTimeMs != null || this.PostCaptureTimeMs != null)) {
|
|
52
|
-
Logger.Info(`Setting CaptureToSendMs Ms \n ${this.PostCaptureTimeMs} \n ${this.PreCaptureTimeMs}`);
|
|
53
|
-
this.CaptureToSendMs = this.PostCaptureTimeMs - this.PreCaptureTimeMs;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
}
|
|
1
|
+
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
2
|
+
import { Logger } from '@epicgames-ps/lib-pixelstreamingcommon-ue5.5';
|
|
3
|
+
/**
|
|
4
|
+
* Latency Test Results Data
|
|
5
|
+
*/
|
|
6
|
+
export class LatencyTestResults {
|
|
7
|
+
constructor() {
|
|
8
|
+
//Fields Set from the latency payload regardless of version
|
|
9
|
+
this.ReceiptTimeMs = null;
|
|
10
|
+
this.TransmissionTimeMs = null;
|
|
11
|
+
//Fields Set from the latency payload from 4.27.2
|
|
12
|
+
this.PreCaptureTimeMs = null;
|
|
13
|
+
this.PostCaptureTimeMs = null;
|
|
14
|
+
this.PreEncodeTimeMs = null;
|
|
15
|
+
this.PostEncodeTimeMs = null;
|
|
16
|
+
//Fields Set from the latency payload from 5.0
|
|
17
|
+
this.EncodeMs = null;
|
|
18
|
+
this.CaptureToSendMs = null;
|
|
19
|
+
//Fields Set when processed
|
|
20
|
+
this.testStartTimeMs = 0;
|
|
21
|
+
this.browserReceiptTimeMs = 0;
|
|
22
|
+
//Fields set from calculations
|
|
23
|
+
this.latencyExcludingDecode = 0;
|
|
24
|
+
this.testDuration = 0;
|
|
25
|
+
//ueLatency: number = 0;
|
|
26
|
+
this.networkLatency = 0;
|
|
27
|
+
this.browserSendLatency = 0;
|
|
28
|
+
this.frameDisplayDeltaTimeMs = 0;
|
|
29
|
+
this.endToEndLatency = 0;
|
|
30
|
+
//uePixelStreamLatency: number = 0;
|
|
31
|
+
this.encodeLatency = 0;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Sets the Delta Time Milliseconds
|
|
35
|
+
* @param DeltaTimeMs - Delta Time Milliseconds
|
|
36
|
+
*/
|
|
37
|
+
setFrameDisplayDeltaTime(DeltaTimeMs) {
|
|
38
|
+
if (this.frameDisplayDeltaTimeMs == 0) {
|
|
39
|
+
this.frameDisplayDeltaTimeMs = Math.round(DeltaTimeMs);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Process the encoder times and set them
|
|
44
|
+
*/
|
|
45
|
+
processFields() {
|
|
46
|
+
if (this.EncodeMs == null && (this.PreEncodeTimeMs != null || this.PostEncodeTimeMs != null)) {
|
|
47
|
+
Logger.Info(`Setting Encode Ms \n ${this.PostEncodeTimeMs} \n ${this.PreEncodeTimeMs}`);
|
|
48
|
+
this.EncodeMs = this.PostEncodeTimeMs - this.PreEncodeTimeMs;
|
|
49
|
+
}
|
|
50
|
+
if (this.CaptureToSendMs == null &&
|
|
51
|
+
(this.PreCaptureTimeMs != null || this.PostCaptureTimeMs != null)) {
|
|
52
|
+
Logger.Info(`Setting CaptureToSendMs Ms \n ${this.PostCaptureTimeMs} \n ${this.PreCaptureTimeMs}`);
|
|
53
|
+
this.CaptureToSendMs = this.PostCaptureTimeMs - this.PreCaptureTimeMs;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
57
|
//# sourceMappingURL=LatencyTestResults.js.map
|
|
@@ -1,90 +1,90 @@
|
|
|
1
|
-
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
2
|
-
/**
|
|
3
|
-
* A class for managing the freeze frame object
|
|
4
|
-
*/
|
|
5
|
-
export class FreezeFrame {
|
|
6
|
-
/**
|
|
7
|
-
* Construct a freeze frame
|
|
8
|
-
* @param rootDiv the div that a freeze frame element will be injected into
|
|
9
|
-
*/
|
|
10
|
-
constructor(rootDiv) {
|
|
11
|
-
this.freezeFrameHeight = 0;
|
|
12
|
-
this.freezeFrameWidth = 0;
|
|
13
|
-
this.rootDiv = rootDiv;
|
|
14
|
-
// create the overlay
|
|
15
|
-
this.rootElement = document.createElement('div');
|
|
16
|
-
this.rootElement.id = 'freezeFrame';
|
|
17
|
-
this.rootElement.style.display = 'none';
|
|
18
|
-
this.rootElement.style.pointerEvents = 'none';
|
|
19
|
-
this.rootElement.style.position = 'absolute';
|
|
20
|
-
this.rootElement.style.zIndex = '20';
|
|
21
|
-
// create the image place holder
|
|
22
|
-
this.imageElement = document.createElement('img');
|
|
23
|
-
this.imageElement.style.position = 'absolute';
|
|
24
|
-
// append the image into the root element and append the element to the root div
|
|
25
|
-
this.rootElement.appendChild(this.imageElement);
|
|
26
|
-
this.rootDiv.appendChild(this.rootElement);
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Set the freeze frame element for showing
|
|
30
|
-
*/
|
|
31
|
-
setElementForShow() {
|
|
32
|
-
this.rootElement.style.display = 'block';
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Set the freeze frame element for hiding
|
|
36
|
-
*/
|
|
37
|
-
setElementForHide() {
|
|
38
|
-
this.rootElement.style.display = 'none';
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Update the freeze frames image source
|
|
42
|
-
* @param jpeg - the freeze frame image as a byte array data
|
|
43
|
-
*/
|
|
44
|
-
updateImageElementSource(jpeg) {
|
|
45
|
-
const base64 = btoa(jpeg.reduce((data, byte) => data + String.fromCharCode(byte), ''));
|
|
46
|
-
this.imageElement.src = 'data:image/jpeg;base64,' + base64;
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Set the dimensions for the freeze frame from the element and resize it
|
|
50
|
-
*/
|
|
51
|
-
setDimensionsFromElementAndResize() {
|
|
52
|
-
this.freezeFrameHeight = this.imageElement.naturalHeight;
|
|
53
|
-
this.freezeFrameWidth = this.imageElement.naturalWidth;
|
|
54
|
-
this.resize();
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Resize a freeze frame element
|
|
58
|
-
*/
|
|
59
|
-
resize() {
|
|
60
|
-
if (this.freezeFrameWidth !== 0 && this.freezeFrameHeight !== 0) {
|
|
61
|
-
let displayWidth = 0;
|
|
62
|
-
let displayHeight = 0;
|
|
63
|
-
let displayTop = 0;
|
|
64
|
-
let displayLeft = 0;
|
|
65
|
-
const parentAspectRatio = this.rootDiv.clientWidth / this.rootDiv.clientHeight;
|
|
66
|
-
const videoAspectRatio = this.freezeFrameWidth / this.freezeFrameHeight;
|
|
67
|
-
if (parentAspectRatio < videoAspectRatio) {
|
|
68
|
-
displayWidth = this.rootDiv.clientWidth;
|
|
69
|
-
displayHeight = Math.floor(this.rootDiv.clientWidth / videoAspectRatio);
|
|
70
|
-
displayTop = Math.floor((this.rootDiv.clientHeight - displayHeight) * 0.5);
|
|
71
|
-
displayLeft = 0;
|
|
72
|
-
}
|
|
73
|
-
else {
|
|
74
|
-
displayWidth = Math.floor(this.rootDiv.clientHeight * videoAspectRatio);
|
|
75
|
-
displayHeight = this.rootDiv.clientHeight;
|
|
76
|
-
displayTop = 0;
|
|
77
|
-
displayLeft = Math.floor((this.rootDiv.clientWidth - displayWidth) * 0.5);
|
|
78
|
-
}
|
|
79
|
-
this.rootElement.style.width = this.rootDiv.offsetWidth + 'px';
|
|
80
|
-
this.rootElement.style.height = this.rootDiv.offsetHeight + 'px';
|
|
81
|
-
this.rootElement.style.left = 0 + 'px';
|
|
82
|
-
this.rootElement.style.top = 0 + 'px';
|
|
83
|
-
this.imageElement.style.width = displayWidth + 'px';
|
|
84
|
-
this.imageElement.style.height = displayHeight + 'px';
|
|
85
|
-
this.imageElement.style.left = displayLeft + 'px';
|
|
86
|
-
this.imageElement.style.top = displayTop + 'px';
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
}
|
|
1
|
+
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
2
|
+
/**
|
|
3
|
+
* A class for managing the freeze frame object
|
|
4
|
+
*/
|
|
5
|
+
export class FreezeFrame {
|
|
6
|
+
/**
|
|
7
|
+
* Construct a freeze frame
|
|
8
|
+
* @param rootDiv the div that a freeze frame element will be injected into
|
|
9
|
+
*/
|
|
10
|
+
constructor(rootDiv) {
|
|
11
|
+
this.freezeFrameHeight = 0;
|
|
12
|
+
this.freezeFrameWidth = 0;
|
|
13
|
+
this.rootDiv = rootDiv;
|
|
14
|
+
// create the overlay
|
|
15
|
+
this.rootElement = document.createElement('div');
|
|
16
|
+
this.rootElement.id = 'freezeFrame';
|
|
17
|
+
this.rootElement.style.display = 'none';
|
|
18
|
+
this.rootElement.style.pointerEvents = 'none';
|
|
19
|
+
this.rootElement.style.position = 'absolute';
|
|
20
|
+
this.rootElement.style.zIndex = '20';
|
|
21
|
+
// create the image place holder
|
|
22
|
+
this.imageElement = document.createElement('img');
|
|
23
|
+
this.imageElement.style.position = 'absolute';
|
|
24
|
+
// append the image into the root element and append the element to the root div
|
|
25
|
+
this.rootElement.appendChild(this.imageElement);
|
|
26
|
+
this.rootDiv.appendChild(this.rootElement);
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Set the freeze frame element for showing
|
|
30
|
+
*/
|
|
31
|
+
setElementForShow() {
|
|
32
|
+
this.rootElement.style.display = 'block';
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Set the freeze frame element for hiding
|
|
36
|
+
*/
|
|
37
|
+
setElementForHide() {
|
|
38
|
+
this.rootElement.style.display = 'none';
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Update the freeze frames image source
|
|
42
|
+
* @param jpeg - the freeze frame image as a byte array data
|
|
43
|
+
*/
|
|
44
|
+
updateImageElementSource(jpeg) {
|
|
45
|
+
const base64 = btoa(jpeg.reduce((data, byte) => data + String.fromCharCode(byte), ''));
|
|
46
|
+
this.imageElement.src = 'data:image/jpeg;base64,' + base64;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Set the dimensions for the freeze frame from the element and resize it
|
|
50
|
+
*/
|
|
51
|
+
setDimensionsFromElementAndResize() {
|
|
52
|
+
this.freezeFrameHeight = this.imageElement.naturalHeight;
|
|
53
|
+
this.freezeFrameWidth = this.imageElement.naturalWidth;
|
|
54
|
+
this.resize();
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Resize a freeze frame element
|
|
58
|
+
*/
|
|
59
|
+
resize() {
|
|
60
|
+
if (this.freezeFrameWidth !== 0 && this.freezeFrameHeight !== 0) {
|
|
61
|
+
let displayWidth = 0;
|
|
62
|
+
let displayHeight = 0;
|
|
63
|
+
let displayTop = 0;
|
|
64
|
+
let displayLeft = 0;
|
|
65
|
+
const parentAspectRatio = this.rootDiv.clientWidth / this.rootDiv.clientHeight;
|
|
66
|
+
const videoAspectRatio = this.freezeFrameWidth / this.freezeFrameHeight;
|
|
67
|
+
if (parentAspectRatio < videoAspectRatio) {
|
|
68
|
+
displayWidth = this.rootDiv.clientWidth;
|
|
69
|
+
displayHeight = Math.floor(this.rootDiv.clientWidth / videoAspectRatio);
|
|
70
|
+
displayTop = Math.floor((this.rootDiv.clientHeight - displayHeight) * 0.5);
|
|
71
|
+
displayLeft = 0;
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
displayWidth = Math.floor(this.rootDiv.clientHeight * videoAspectRatio);
|
|
75
|
+
displayHeight = this.rootDiv.clientHeight;
|
|
76
|
+
displayTop = 0;
|
|
77
|
+
displayLeft = Math.floor((this.rootDiv.clientWidth - displayWidth) * 0.5);
|
|
78
|
+
}
|
|
79
|
+
this.rootElement.style.width = this.rootDiv.offsetWidth + 'px';
|
|
80
|
+
this.rootElement.style.height = this.rootDiv.offsetHeight + 'px';
|
|
81
|
+
this.rootElement.style.left = 0 + 'px';
|
|
82
|
+
this.rootElement.style.top = 0 + 'px';
|
|
83
|
+
this.imageElement.style.width = displayWidth + 'px';
|
|
84
|
+
this.imageElement.style.height = displayHeight + 'px';
|
|
85
|
+
this.imageElement.style.left = displayLeft + 'px';
|
|
86
|
+
this.imageElement.style.top = displayTop + 'px';
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
90
|
//# sourceMappingURL=FreezeFrame.js.map
|
|
@@ -1,92 +1,92 @@
|
|
|
1
|
-
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
2
|
-
import { Logger } from '@epicgames-ps/lib-pixelstreamingcommon-ue5.5';
|
|
3
|
-
import { FreezeFrame } from './FreezeFrame';
|
|
4
|
-
/**
|
|
5
|
-
* A class for controlling freeze frame functionality
|
|
6
|
-
*/
|
|
7
|
-
export class FreezeFrameController {
|
|
8
|
-
/**
|
|
9
|
-
* Construct a freeze frame controller
|
|
10
|
-
* @param rootDiv - the div that a freeze frame element will be injected into
|
|
11
|
-
*/
|
|
12
|
-
constructor(rootDiv) {
|
|
13
|
-
this.receiving = false;
|
|
14
|
-
this.size = 0;
|
|
15
|
-
this.jpeg = undefined;
|
|
16
|
-
this.valid = false;
|
|
17
|
-
this.freezeFrameDelay = 50;
|
|
18
|
-
this.freezeFrame = new FreezeFrame(rootDiv);
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Show the freeze frame if it is valid
|
|
22
|
-
*/
|
|
23
|
-
showFreezeFrame() {
|
|
24
|
-
if (this.valid) {
|
|
25
|
-
this.freezeFrame.setElementForShow();
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Hide the freeze frame and set the validity to false
|
|
30
|
-
*/
|
|
31
|
-
hideFreezeFrame() {
|
|
32
|
-
this.valid = false;
|
|
33
|
-
this.freezeFrame.setElementForHide();
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Update the freeze frames image source and load it
|
|
37
|
-
* @param jpeg - the freeze frame image as a byte array data
|
|
38
|
-
* @param onLoadCallBack - a call back for managing if the play overlay needs to be shown or not
|
|
39
|
-
*/
|
|
40
|
-
updateFreezeFrameAndShow(jpeg, onLoadCallBack) {
|
|
41
|
-
this.freezeFrame.updateImageElementSource(jpeg);
|
|
42
|
-
this.freezeFrame.imageElement.onload = () => {
|
|
43
|
-
this.freezeFrame.setDimensionsFromElementAndResize();
|
|
44
|
-
onLoadCallBack();
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Process the new freeze frame image and update it
|
|
49
|
-
* @param view - the freeze frame image as a byte array data
|
|
50
|
-
* @param onLoadCallBack - a call back for managing if the play overlay needs to be shown or not
|
|
51
|
-
*/
|
|
52
|
-
processFreezeFrameMessage(view, onLoadCallBack) {
|
|
53
|
-
// Reset freeze frame if we got a freeze frame message and we are not "receiving" yet.
|
|
54
|
-
if (!this.receiving) {
|
|
55
|
-
this.receiving = true;
|
|
56
|
-
this.valid = false;
|
|
57
|
-
this.size = 0;
|
|
58
|
-
this.jpeg = undefined;
|
|
59
|
-
}
|
|
60
|
-
// Extract total size of freeze frame (across all chunks)
|
|
61
|
-
this.size = new DataView(view.slice(1, 5).buffer).getInt32(0, true);
|
|
62
|
-
// Get the jpeg part of the payload
|
|
63
|
-
const jpegBytes = view.slice(1 + 4);
|
|
64
|
-
// Append to existing jpeg that holds the freeze frame
|
|
65
|
-
if (this.jpeg) {
|
|
66
|
-
const jpeg = new Uint8Array(this.jpeg.length + jpegBytes.length);
|
|
67
|
-
jpeg.set(this.jpeg, 0);
|
|
68
|
-
jpeg.set(jpegBytes, this.jpeg.length);
|
|
69
|
-
this.jpeg = jpeg;
|
|
70
|
-
}
|
|
71
|
-
// No existing freeze frame jpeg, make one
|
|
72
|
-
else {
|
|
73
|
-
this.jpeg = jpegBytes;
|
|
74
|
-
this.receiving = true;
|
|
75
|
-
Logger.Info(`received first chunk of freeze frame: ${this.jpeg.length}/${this.size}`);
|
|
76
|
-
}
|
|
77
|
-
// Finished receiving freeze frame, we can show it now
|
|
78
|
-
if (this.jpeg.length === this.size) {
|
|
79
|
-
this.receiving = false;
|
|
80
|
-
this.valid = true;
|
|
81
|
-
Logger.Info(`received complete freeze frame ${this.size}`);
|
|
82
|
-
this.updateFreezeFrameAndShow(this.jpeg, onLoadCallBack);
|
|
83
|
-
}
|
|
84
|
-
// We received more data than the freeze frame payload message indicate (this is an error)
|
|
85
|
-
else if (this.jpeg.length > this.size) {
|
|
86
|
-
Logger.Error(`received bigger freeze frame than advertised: ${this.jpeg.length}/${this.size}`);
|
|
87
|
-
this.jpeg = undefined;
|
|
88
|
-
this.receiving = false;
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
}
|
|
1
|
+
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
2
|
+
import { Logger } from '@epicgames-ps/lib-pixelstreamingcommon-ue5.5';
|
|
3
|
+
import { FreezeFrame } from './FreezeFrame';
|
|
4
|
+
/**
|
|
5
|
+
* A class for controlling freeze frame functionality
|
|
6
|
+
*/
|
|
7
|
+
export class FreezeFrameController {
|
|
8
|
+
/**
|
|
9
|
+
* Construct a freeze frame controller
|
|
10
|
+
* @param rootDiv - the div that a freeze frame element will be injected into
|
|
11
|
+
*/
|
|
12
|
+
constructor(rootDiv) {
|
|
13
|
+
this.receiving = false;
|
|
14
|
+
this.size = 0;
|
|
15
|
+
this.jpeg = undefined;
|
|
16
|
+
this.valid = false;
|
|
17
|
+
this.freezeFrameDelay = 50;
|
|
18
|
+
this.freezeFrame = new FreezeFrame(rootDiv);
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Show the freeze frame if it is valid
|
|
22
|
+
*/
|
|
23
|
+
showFreezeFrame() {
|
|
24
|
+
if (this.valid) {
|
|
25
|
+
this.freezeFrame.setElementForShow();
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Hide the freeze frame and set the validity to false
|
|
30
|
+
*/
|
|
31
|
+
hideFreezeFrame() {
|
|
32
|
+
this.valid = false;
|
|
33
|
+
this.freezeFrame.setElementForHide();
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Update the freeze frames image source and load it
|
|
37
|
+
* @param jpeg - the freeze frame image as a byte array data
|
|
38
|
+
* @param onLoadCallBack - a call back for managing if the play overlay needs to be shown or not
|
|
39
|
+
*/
|
|
40
|
+
updateFreezeFrameAndShow(jpeg, onLoadCallBack) {
|
|
41
|
+
this.freezeFrame.updateImageElementSource(jpeg);
|
|
42
|
+
this.freezeFrame.imageElement.onload = () => {
|
|
43
|
+
this.freezeFrame.setDimensionsFromElementAndResize();
|
|
44
|
+
onLoadCallBack();
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Process the new freeze frame image and update it
|
|
49
|
+
* @param view - the freeze frame image as a byte array data
|
|
50
|
+
* @param onLoadCallBack - a call back for managing if the play overlay needs to be shown or not
|
|
51
|
+
*/
|
|
52
|
+
processFreezeFrameMessage(view, onLoadCallBack) {
|
|
53
|
+
// Reset freeze frame if we got a freeze frame message and we are not "receiving" yet.
|
|
54
|
+
if (!this.receiving) {
|
|
55
|
+
this.receiving = true;
|
|
56
|
+
this.valid = false;
|
|
57
|
+
this.size = 0;
|
|
58
|
+
this.jpeg = undefined;
|
|
59
|
+
}
|
|
60
|
+
// Extract total size of freeze frame (across all chunks)
|
|
61
|
+
this.size = new DataView(view.slice(1, 5).buffer).getInt32(0, true);
|
|
62
|
+
// Get the jpeg part of the payload
|
|
63
|
+
const jpegBytes = view.slice(1 + 4);
|
|
64
|
+
// Append to existing jpeg that holds the freeze frame
|
|
65
|
+
if (this.jpeg) {
|
|
66
|
+
const jpeg = new Uint8Array(this.jpeg.length + jpegBytes.length);
|
|
67
|
+
jpeg.set(this.jpeg, 0);
|
|
68
|
+
jpeg.set(jpegBytes, this.jpeg.length);
|
|
69
|
+
this.jpeg = jpeg;
|
|
70
|
+
}
|
|
71
|
+
// No existing freeze frame jpeg, make one
|
|
72
|
+
else {
|
|
73
|
+
this.jpeg = jpegBytes;
|
|
74
|
+
this.receiving = true;
|
|
75
|
+
Logger.Info(`received first chunk of freeze frame: ${this.jpeg.length}/${this.size}`);
|
|
76
|
+
}
|
|
77
|
+
// Finished receiving freeze frame, we can show it now
|
|
78
|
+
if (this.jpeg.length === this.size) {
|
|
79
|
+
this.receiving = false;
|
|
80
|
+
this.valid = true;
|
|
81
|
+
Logger.Info(`received complete freeze frame ${this.size}`);
|
|
82
|
+
this.updateFreezeFrameAndShow(this.jpeg, onLoadCallBack);
|
|
83
|
+
}
|
|
84
|
+
// We received more data than the freeze frame payload message indicate (this is an error)
|
|
85
|
+
else if (this.jpeg.length > this.size) {
|
|
86
|
+
Logger.Error(`received bigger freeze frame than advertised: ${this.jpeg.length}/${this.size}`);
|
|
87
|
+
this.jpeg = undefined;
|
|
88
|
+
this.receiving = false;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
92
|
//# sourceMappingURL=FreezeFrameController.js.map
|