@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.
Files changed (169) hide show
  1. package/dist/commonjs/AFK/AFKController.js +109 -109
  2. package/dist/commonjs/Config/Config.js +559 -559
  3. package/dist/commonjs/Config/SettingBase.js +98 -98
  4. package/dist/commonjs/Config/SettingFlag.js +49 -49
  5. package/dist/commonjs/Config/SettingNumber.js +83 -83
  6. package/dist/commonjs/Config/SettingOption.js +84 -84
  7. package/dist/commonjs/Config/SettingText.js +42 -42
  8. package/dist/commonjs/DataChannel/DataChannelController.js +106 -106
  9. package/dist/commonjs/DataChannel/DataChannelLatencyTestController.js +94 -94
  10. package/dist/commonjs/DataChannel/DataChannelLatencyTestResults.js +18 -18
  11. package/dist/commonjs/DataChannel/DataChannelSender.js +43 -43
  12. package/dist/commonjs/DataChannel/InitialSettings.js +41 -41
  13. package/dist/commonjs/DataChannel/LatencyTestResults.js +60 -60
  14. package/dist/commonjs/FreezeFrame/FreezeFrame.js +93 -93
  15. package/dist/commonjs/FreezeFrame/FreezeFrameController.js +95 -95
  16. package/dist/commonjs/Inputs/GamepadController.js +188 -188
  17. package/dist/commonjs/Inputs/GamepadTypes.js +21 -21
  18. package/dist/commonjs/Inputs/IInputController.js +2 -2
  19. package/dist/commonjs/Inputs/InputClassesFactory.js +96 -96
  20. package/dist/commonjs/Inputs/KeyCodes.js +112 -112
  21. package/dist/commonjs/Inputs/KeyboardController.js +137 -137
  22. package/dist/commonjs/Inputs/MouseButtons.js +28 -28
  23. package/dist/commonjs/Inputs/MouseController.js +97 -97
  24. package/dist/commonjs/Inputs/MouseControllerHovering.js +93 -93
  25. package/dist/commonjs/Inputs/MouseControllerLocked.js +153 -153
  26. package/dist/commonjs/Inputs/SpecialKeyCodes.js +19 -19
  27. package/dist/commonjs/Inputs/TouchController.js +123 -123
  28. package/dist/commonjs/Inputs/TouchControllerFake.js +91 -91
  29. package/dist/commonjs/Inputs/XRGamepadController.js +124 -124
  30. package/dist/commonjs/PeerConnectionController/AggregatedStats.js +252 -252
  31. package/dist/commonjs/PeerConnectionController/CandidatePairStats.js +10 -10
  32. package/dist/commonjs/PeerConnectionController/CandidateStat.js +10 -10
  33. package/dist/commonjs/PeerConnectionController/CodecStats.js +10 -10
  34. package/dist/commonjs/PeerConnectionController/DataChannelStats.js +10 -10
  35. package/dist/commonjs/PeerConnectionController/InboundRTPStats.js +22 -22
  36. package/dist/commonjs/PeerConnectionController/InboundTrackStats.js +10 -10
  37. package/dist/commonjs/PeerConnectionController/OutBoundRTPStats.js +16 -16
  38. package/dist/commonjs/PeerConnectionController/PeerConnectionController.js +584 -584
  39. package/dist/commonjs/PeerConnectionController/SessionStats.js +10 -10
  40. package/dist/commonjs/PeerConnectionController/StreamStats.js +10 -10
  41. package/dist/commonjs/PixelStreaming/PixelStreaming.js +607 -607
  42. package/dist/commonjs/UI/OnScreenKeyboard.js +82 -82
  43. package/dist/commonjs/UeInstanceMessage/ResponseController.js +38 -38
  44. package/dist/commonjs/UeInstanceMessage/SendMessageController.js +120 -120
  45. package/dist/commonjs/UeInstanceMessage/StreamMessageController.js +210 -210
  46. package/dist/commonjs/UeInstanceMessage/ToStreamerMessagesController.js +49 -49
  47. package/dist/commonjs/Util/EventEmitter.js +386 -386
  48. package/dist/commonjs/Util/FileUtil.js +108 -108
  49. package/dist/commonjs/Util/IURLSearchParams.js +25 -25
  50. package/dist/commonjs/Util/InputCoordTranslator.js +49 -49
  51. package/dist/commonjs/Util/RTCUtils.js +40 -40
  52. package/dist/commonjs/VideoPlayer/StreamController.js +67 -67
  53. package/dist/commonjs/VideoPlayer/VideoPlayer.js +177 -177
  54. package/dist/commonjs/WebRtcPlayer/WebRtcPlayerController.js +1221 -1221
  55. package/dist/commonjs/WebXR/WebXRController.js +335 -335
  56. package/dist/commonjs/pixelstreamingfrontend.js +70 -70
  57. package/dist/esm/AFK/AFKController.js +105 -105
  58. package/dist/esm/Config/Config.js +551 -551
  59. package/dist/esm/Config/SettingBase.js +94 -94
  60. package/dist/esm/Config/SettingFlag.js +45 -45
  61. package/dist/esm/Config/SettingNumber.js +79 -79
  62. package/dist/esm/Config/SettingOption.js +80 -80
  63. package/dist/esm/Config/SettingText.js +38 -38
  64. package/dist/esm/DataChannel/DataChannelController.js +102 -102
  65. package/dist/esm/DataChannel/DataChannelLatencyTestController.js +90 -90
  66. package/dist/esm/DataChannel/DataChannelLatencyTestResults.js +14 -14
  67. package/dist/esm/DataChannel/DataChannelSender.js +39 -39
  68. package/dist/esm/DataChannel/InitialSettings.js +34 -34
  69. package/dist/esm/DataChannel/LatencyTestResults.js +56 -56
  70. package/dist/esm/FreezeFrame/FreezeFrame.js +89 -89
  71. package/dist/esm/FreezeFrame/FreezeFrameController.js +91 -91
  72. package/dist/esm/Inputs/GamepadController.js +184 -184
  73. package/dist/esm/Inputs/GamepadTypes.js +17 -17
  74. package/dist/esm/Inputs/IInputController.js +1 -1
  75. package/dist/esm/Inputs/InputClassesFactory.js +91 -91
  76. package/dist/esm/Inputs/KeyCodes.js +109 -109
  77. package/dist/esm/Inputs/KeyboardController.js +133 -133
  78. package/dist/esm/Inputs/MouseButtons.js +23 -23
  79. package/dist/esm/Inputs/MouseController.js +93 -93
  80. package/dist/esm/Inputs/MouseControllerHovering.js +89 -89
  81. package/dist/esm/Inputs/MouseControllerLocked.js +149 -149
  82. package/dist/esm/Inputs/SpecialKeyCodes.js +15 -15
  83. package/dist/esm/Inputs/TouchController.js +119 -119
  84. package/dist/esm/Inputs/TouchControllerFake.js +87 -87
  85. package/dist/esm/Inputs/XRGamepadController.js +120 -120
  86. package/dist/esm/PeerConnectionController/AggregatedStats.js +248 -248
  87. package/dist/esm/PeerConnectionController/CandidatePairStats.js +6 -6
  88. package/dist/esm/PeerConnectionController/CandidateStat.js +6 -6
  89. package/dist/esm/PeerConnectionController/CodecStats.js +6 -6
  90. package/dist/esm/PeerConnectionController/DataChannelStats.js +6 -6
  91. package/dist/esm/PeerConnectionController/InboundRTPStats.js +16 -16
  92. package/dist/esm/PeerConnectionController/InboundTrackStats.js +6 -6
  93. package/dist/esm/PeerConnectionController/OutBoundRTPStats.js +11 -11
  94. package/dist/esm/PeerConnectionController/PeerConnectionController.js +580 -580
  95. package/dist/esm/PeerConnectionController/SessionStats.js +6 -6
  96. package/dist/esm/PeerConnectionController/StreamStats.js +6 -6
  97. package/dist/esm/PixelStreaming/PixelStreaming.js +603 -603
  98. package/dist/esm/UI/OnScreenKeyboard.js +78 -78
  99. package/dist/esm/UeInstanceMessage/ResponseController.js +34 -34
  100. package/dist/esm/UeInstanceMessage/SendMessageController.js +116 -116
  101. package/dist/esm/UeInstanceMessage/StreamMessageController.js +205 -205
  102. package/dist/esm/UeInstanceMessage/ToStreamerMessagesController.js +45 -45
  103. package/dist/esm/Util/EventEmitter.js +345 -345
  104. package/dist/esm/Util/FileUtil.js +103 -103
  105. package/dist/esm/Util/IURLSearchParams.js +21 -21
  106. package/dist/esm/Util/InputCoordTranslator.js +45 -45
  107. package/dist/esm/Util/RTCUtils.js +36 -36
  108. package/dist/esm/VideoPlayer/StreamController.js +63 -63
  109. package/dist/esm/VideoPlayer/VideoPlayer.js +173 -173
  110. package/dist/esm/WebRtcPlayer/WebRtcPlayerController.js +1217 -1217
  111. package/dist/esm/WebXR/WebXRController.js +331 -331
  112. package/dist/esm/pixelstreamingfrontend.js +24 -24
  113. package/dist/types/AFK/AFKController.d.ts +38 -38
  114. package/dist/types/Config/Config.d.ts +220 -220
  115. package/dist/types/Config/SettingBase.d.ts +43 -43
  116. package/dist/types/Config/SettingFlag.d.ts +24 -24
  117. package/dist/types/Config/SettingNumber.d.ts +41 -41
  118. package/dist/types/Config/SettingOption.d.ts +41 -41
  119. package/dist/types/Config/SettingText.d.ts +21 -21
  120. package/dist/types/DataChannel/DataChannelController.d.ts +59 -59
  121. package/dist/types/DataChannel/DataChannelLatencyTestController.d.ts +25 -25
  122. package/dist/types/DataChannel/DataChannelLatencyTestResults.d.ts +46 -46
  123. package/dist/types/DataChannel/DataChannelSender.d.ts +21 -21
  124. package/dist/types/DataChannel/InitialSettings.d.ts +44 -44
  125. package/dist/types/DataChannel/LatencyTestResults.d.ts +31 -31
  126. package/dist/types/FreezeFrame/FreezeFrame.d.ts +36 -36
  127. package/dist/types/FreezeFrame/FreezeFrameController.d.ts +37 -37
  128. package/dist/types/Inputs/GamepadController.d.ts +61 -61
  129. package/dist/types/Inputs/GamepadTypes.d.ts +15 -15
  130. package/dist/types/Inputs/IInputController.d.ts +16 -16
  131. package/dist/types/Inputs/InputClassesFactory.d.ts +53 -53
  132. package/dist/types/Inputs/KeyCodes.d.ts +5 -5
  133. package/dist/types/Inputs/KeyboardController.d.ts +34 -34
  134. package/dist/types/Inputs/MouseButtons.d.ts +22 -22
  135. package/dist/types/Inputs/MouseController.d.ts +40 -40
  136. package/dist/types/Inputs/MouseControllerHovering.d.ts +26 -26
  137. package/dist/types/Inputs/MouseControllerLocked.d.ts +31 -31
  138. package/dist/types/Inputs/SpecialKeyCodes.d.ts +14 -14
  139. package/dist/types/Inputs/TouchController.d.ts +28 -28
  140. package/dist/types/Inputs/TouchControllerFake.d.ts +29 -29
  141. package/dist/types/Inputs/XRGamepadController.d.ts +15 -15
  142. package/dist/types/PeerConnectionController/AggregatedStats.d.ts +82 -82
  143. package/dist/types/PeerConnectionController/CandidatePairStats.d.ts +22 -22
  144. package/dist/types/PeerConnectionController/CandidateStat.d.ts +13 -13
  145. package/dist/types/PeerConnectionController/CodecStats.d.ts +14 -14
  146. package/dist/types/PeerConnectionController/DataChannelStats.d.ts +15 -15
  147. package/dist/types/PeerConnectionController/InboundRTPStats.d.ts +141 -141
  148. package/dist/types/PeerConnectionController/InboundTrackStats.d.ts +32 -32
  149. package/dist/types/PeerConnectionController/OutBoundRTPStats.d.ts +23 -23
  150. package/dist/types/PeerConnectionController/PeerConnectionController.d.ts +143 -143
  151. package/dist/types/PeerConnectionController/SessionStats.d.ts +8 -8
  152. package/dist/types/PeerConnectionController/StreamStats.d.ts +9 -9
  153. package/dist/types/PixelStreaming/PixelStreaming.d.ts +271 -271
  154. package/dist/types/UI/OnScreenKeyboard.d.ts +30 -30
  155. package/dist/types/UeInstanceMessage/ResponseController.d.ts +19 -19
  156. package/dist/types/UeInstanceMessage/SendMessageController.d.ts +18 -18
  157. package/dist/types/UeInstanceMessage/StreamMessageController.d.ts +29 -29
  158. package/dist/types/UeInstanceMessage/ToStreamerMessagesController.d.ts +32 -32
  159. package/dist/types/Util/EventEmitter.d.ts +429 -429
  160. package/dist/types/Util/FileUtil.d.ts +32 -32
  161. package/dist/types/Util/IURLSearchParams.d.ts +9 -9
  162. package/dist/types/Util/InputCoordTranslator.d.ts +29 -29
  163. package/dist/types/Util/RTCUtils.d.ts +8 -8
  164. package/dist/types/VideoPlayer/StreamController.d.ts +22 -22
  165. package/dist/types/VideoPlayer/VideoPlayer.d.ts +78 -78
  166. package/dist/types/WebRtcPlayer/WebRtcPlayerController.d.ts +379 -379
  167. package/dist/types/WebXR/WebXRController.d.ts +42 -42
  168. package/dist/types/pixelstreamingfrontend.d.ts +23 -23
  169. package/package.json +45 -45
@@ -1,42 +1,42 @@
1
- "use strict";
2
- // Copyright Epic Games, Inc. All Rights Reserved.
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.WebRTCSettings = exports.EncoderSettings = exports.PixelStreamingSettings = exports.InitialSettings = void 0;
5
- /**
6
- * Latency Test Results Data
7
- */
8
- class InitialSettings {
9
- constructor() {
10
- this.PixelStreamingSettings = new PixelStreamingSettings();
11
- this.EncoderSettings = new EncoderSettings();
12
- this.WebRTCSettings = new WebRTCSettings();
13
- }
14
- /**
15
- * Checks for compatibility with the FPS and MaxFPS stats between 4.27 and 5
16
- */
17
- ueCompatible() {
18
- if (this.WebRTCSettings.MaxFPS != null) {
19
- this.WebRTCSettings.FPS = this.WebRTCSettings.MaxFPS;
20
- }
21
- }
22
- }
23
- exports.InitialSettings = InitialSettings;
24
- /**
25
- * A class for handling Pixel Streaming details
26
- */
27
- class PixelStreamingSettings {
28
- }
29
- exports.PixelStreamingSettings = PixelStreamingSettings;
30
- /**
31
- * A class for handling encoder stats
32
- */
33
- class EncoderSettings {
34
- }
35
- exports.EncoderSettings = EncoderSettings;
36
- /**
37
- * A class for handling web rtc stats
38
- */
39
- class WebRTCSettings {
40
- }
41
- exports.WebRTCSettings = WebRTCSettings;
1
+ "use strict";
2
+ // Copyright Epic Games, Inc. All Rights Reserved.
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.WebRTCSettings = exports.EncoderSettings = exports.PixelStreamingSettings = exports.InitialSettings = void 0;
5
+ /**
6
+ * Latency Test Results Data
7
+ */
8
+ class InitialSettings {
9
+ constructor() {
10
+ this.PixelStreamingSettings = new PixelStreamingSettings();
11
+ this.EncoderSettings = new EncoderSettings();
12
+ this.WebRTCSettings = new WebRTCSettings();
13
+ }
14
+ /**
15
+ * Checks for compatibility with the FPS and MaxFPS stats between 4.27 and 5
16
+ */
17
+ ueCompatible() {
18
+ if (this.WebRTCSettings.MaxFPS != null) {
19
+ this.WebRTCSettings.FPS = this.WebRTCSettings.MaxFPS;
20
+ }
21
+ }
22
+ }
23
+ exports.InitialSettings = InitialSettings;
24
+ /**
25
+ * A class for handling Pixel Streaming details
26
+ */
27
+ class PixelStreamingSettings {
28
+ }
29
+ exports.PixelStreamingSettings = PixelStreamingSettings;
30
+ /**
31
+ * A class for handling encoder stats
32
+ */
33
+ class EncoderSettings {
34
+ }
35
+ exports.EncoderSettings = EncoderSettings;
36
+ /**
37
+ * A class for handling web rtc stats
38
+ */
39
+ class WebRTCSettings {
40
+ }
41
+ exports.WebRTCSettings = WebRTCSettings;
42
42
  //# sourceMappingURL=InitialSettings.js.map
@@ -1,61 +1,61 @@
1
- "use strict";
2
- // Copyright Epic Games, Inc. All Rights Reserved.
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.LatencyTestResults = void 0;
5
- const lib_pixelstreamingcommon_ue5_5_1 = require("@epicgames-ps/lib-pixelstreamingcommon-ue5.5");
6
- /**
7
- * Latency Test Results Data
8
- */
9
- class LatencyTestResults {
10
- constructor() {
11
- //Fields Set from the latency payload regardless of version
12
- this.ReceiptTimeMs = null;
13
- this.TransmissionTimeMs = null;
14
- //Fields Set from the latency payload from 4.27.2
15
- this.PreCaptureTimeMs = null;
16
- this.PostCaptureTimeMs = null;
17
- this.PreEncodeTimeMs = null;
18
- this.PostEncodeTimeMs = null;
19
- //Fields Set from the latency payload from 5.0
20
- this.EncodeMs = null;
21
- this.CaptureToSendMs = null;
22
- //Fields Set when processed
23
- this.testStartTimeMs = 0;
24
- this.browserReceiptTimeMs = 0;
25
- //Fields set from calculations
26
- this.latencyExcludingDecode = 0;
27
- this.testDuration = 0;
28
- //ueLatency: number = 0;
29
- this.networkLatency = 0;
30
- this.browserSendLatency = 0;
31
- this.frameDisplayDeltaTimeMs = 0;
32
- this.endToEndLatency = 0;
33
- //uePixelStreamLatency: number = 0;
34
- this.encodeLatency = 0;
35
- }
36
- /**
37
- * Sets the Delta Time Milliseconds
38
- * @param DeltaTimeMs - Delta Time Milliseconds
39
- */
40
- setFrameDisplayDeltaTime(DeltaTimeMs) {
41
- if (this.frameDisplayDeltaTimeMs == 0) {
42
- this.frameDisplayDeltaTimeMs = Math.round(DeltaTimeMs);
43
- }
44
- }
45
- /**
46
- * Process the encoder times and set them
47
- */
48
- processFields() {
49
- if (this.EncodeMs == null && (this.PreEncodeTimeMs != null || this.PostEncodeTimeMs != null)) {
50
- lib_pixelstreamingcommon_ue5_5_1.Logger.Info(`Setting Encode Ms \n ${this.PostEncodeTimeMs} \n ${this.PreEncodeTimeMs}`);
51
- this.EncodeMs = this.PostEncodeTimeMs - this.PreEncodeTimeMs;
52
- }
53
- if (this.CaptureToSendMs == null &&
54
- (this.PreCaptureTimeMs != null || this.PostCaptureTimeMs != null)) {
55
- lib_pixelstreamingcommon_ue5_5_1.Logger.Info(`Setting CaptureToSendMs Ms \n ${this.PostCaptureTimeMs} \n ${this.PreCaptureTimeMs}`);
56
- this.CaptureToSendMs = this.PostCaptureTimeMs - this.PreCaptureTimeMs;
57
- }
58
- }
59
- }
60
- exports.LatencyTestResults = LatencyTestResults;
1
+ "use strict";
2
+ // Copyright Epic Games, Inc. All Rights Reserved.
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.LatencyTestResults = void 0;
5
+ const lib_pixelstreamingcommon_ue5_5_1 = require("@epicgames-ps/lib-pixelstreamingcommon-ue5.5");
6
+ /**
7
+ * Latency Test Results Data
8
+ */
9
+ class LatencyTestResults {
10
+ constructor() {
11
+ //Fields Set from the latency payload regardless of version
12
+ this.ReceiptTimeMs = null;
13
+ this.TransmissionTimeMs = null;
14
+ //Fields Set from the latency payload from 4.27.2
15
+ this.PreCaptureTimeMs = null;
16
+ this.PostCaptureTimeMs = null;
17
+ this.PreEncodeTimeMs = null;
18
+ this.PostEncodeTimeMs = null;
19
+ //Fields Set from the latency payload from 5.0
20
+ this.EncodeMs = null;
21
+ this.CaptureToSendMs = null;
22
+ //Fields Set when processed
23
+ this.testStartTimeMs = 0;
24
+ this.browserReceiptTimeMs = 0;
25
+ //Fields set from calculations
26
+ this.latencyExcludingDecode = 0;
27
+ this.testDuration = 0;
28
+ //ueLatency: number = 0;
29
+ this.networkLatency = 0;
30
+ this.browserSendLatency = 0;
31
+ this.frameDisplayDeltaTimeMs = 0;
32
+ this.endToEndLatency = 0;
33
+ //uePixelStreamLatency: number = 0;
34
+ this.encodeLatency = 0;
35
+ }
36
+ /**
37
+ * Sets the Delta Time Milliseconds
38
+ * @param DeltaTimeMs - Delta Time Milliseconds
39
+ */
40
+ setFrameDisplayDeltaTime(DeltaTimeMs) {
41
+ if (this.frameDisplayDeltaTimeMs == 0) {
42
+ this.frameDisplayDeltaTimeMs = Math.round(DeltaTimeMs);
43
+ }
44
+ }
45
+ /**
46
+ * Process the encoder times and set them
47
+ */
48
+ processFields() {
49
+ if (this.EncodeMs == null && (this.PreEncodeTimeMs != null || this.PostEncodeTimeMs != null)) {
50
+ lib_pixelstreamingcommon_ue5_5_1.Logger.Info(`Setting Encode Ms \n ${this.PostEncodeTimeMs} \n ${this.PreEncodeTimeMs}`);
51
+ this.EncodeMs = this.PostEncodeTimeMs - this.PreEncodeTimeMs;
52
+ }
53
+ if (this.CaptureToSendMs == null &&
54
+ (this.PreCaptureTimeMs != null || this.PostCaptureTimeMs != null)) {
55
+ lib_pixelstreamingcommon_ue5_5_1.Logger.Info(`Setting CaptureToSendMs Ms \n ${this.PostCaptureTimeMs} \n ${this.PreCaptureTimeMs}`);
56
+ this.CaptureToSendMs = this.PostCaptureTimeMs - this.PreCaptureTimeMs;
57
+ }
58
+ }
59
+ }
60
+ exports.LatencyTestResults = LatencyTestResults;
61
61
  //# sourceMappingURL=LatencyTestResults.js.map
@@ -1,94 +1,94 @@
1
- "use strict";
2
- // Copyright Epic Games, Inc. All Rights Reserved.
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.FreezeFrame = void 0;
5
- /**
6
- * A class for managing the freeze frame object
7
- */
8
- class FreezeFrame {
9
- /**
10
- * Construct a freeze frame
11
- * @param rootDiv the div that a freeze frame element will be injected into
12
- */
13
- constructor(rootDiv) {
14
- this.freezeFrameHeight = 0;
15
- this.freezeFrameWidth = 0;
16
- this.rootDiv = rootDiv;
17
- // create the overlay
18
- this.rootElement = document.createElement('div');
19
- this.rootElement.id = 'freezeFrame';
20
- this.rootElement.style.display = 'none';
21
- this.rootElement.style.pointerEvents = 'none';
22
- this.rootElement.style.position = 'absolute';
23
- this.rootElement.style.zIndex = '20';
24
- // create the image place holder
25
- this.imageElement = document.createElement('img');
26
- this.imageElement.style.position = 'absolute';
27
- // append the image into the root element and append the element to the root div
28
- this.rootElement.appendChild(this.imageElement);
29
- this.rootDiv.appendChild(this.rootElement);
30
- }
31
- /**
32
- * Set the freeze frame element for showing
33
- */
34
- setElementForShow() {
35
- this.rootElement.style.display = 'block';
36
- }
37
- /**
38
- * Set the freeze frame element for hiding
39
- */
40
- setElementForHide() {
41
- this.rootElement.style.display = 'none';
42
- }
43
- /**
44
- * Update the freeze frames image source
45
- * @param jpeg - the freeze frame image as a byte array data
46
- */
47
- updateImageElementSource(jpeg) {
48
- const base64 = btoa(jpeg.reduce((data, byte) => data + String.fromCharCode(byte), ''));
49
- this.imageElement.src = 'data:image/jpeg;base64,' + base64;
50
- }
51
- /**
52
- * Set the dimensions for the freeze frame from the element and resize it
53
- */
54
- setDimensionsFromElementAndResize() {
55
- this.freezeFrameHeight = this.imageElement.naturalHeight;
56
- this.freezeFrameWidth = this.imageElement.naturalWidth;
57
- this.resize();
58
- }
59
- /**
60
- * Resize a freeze frame element
61
- */
62
- resize() {
63
- if (this.freezeFrameWidth !== 0 && this.freezeFrameHeight !== 0) {
64
- let displayWidth = 0;
65
- let displayHeight = 0;
66
- let displayTop = 0;
67
- let displayLeft = 0;
68
- const parentAspectRatio = this.rootDiv.clientWidth / this.rootDiv.clientHeight;
69
- const videoAspectRatio = this.freezeFrameWidth / this.freezeFrameHeight;
70
- if (parentAspectRatio < videoAspectRatio) {
71
- displayWidth = this.rootDiv.clientWidth;
72
- displayHeight = Math.floor(this.rootDiv.clientWidth / videoAspectRatio);
73
- displayTop = Math.floor((this.rootDiv.clientHeight - displayHeight) * 0.5);
74
- displayLeft = 0;
75
- }
76
- else {
77
- displayWidth = Math.floor(this.rootDiv.clientHeight * videoAspectRatio);
78
- displayHeight = this.rootDiv.clientHeight;
79
- displayTop = 0;
80
- displayLeft = Math.floor((this.rootDiv.clientWidth - displayWidth) * 0.5);
81
- }
82
- this.rootElement.style.width = this.rootDiv.offsetWidth + 'px';
83
- this.rootElement.style.height = this.rootDiv.offsetHeight + 'px';
84
- this.rootElement.style.left = 0 + 'px';
85
- this.rootElement.style.top = 0 + 'px';
86
- this.imageElement.style.width = displayWidth + 'px';
87
- this.imageElement.style.height = displayHeight + 'px';
88
- this.imageElement.style.left = displayLeft + 'px';
89
- this.imageElement.style.top = displayTop + 'px';
90
- }
91
- }
92
- }
93
- exports.FreezeFrame = FreezeFrame;
1
+ "use strict";
2
+ // Copyright Epic Games, Inc. All Rights Reserved.
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.FreezeFrame = void 0;
5
+ /**
6
+ * A class for managing the freeze frame object
7
+ */
8
+ class FreezeFrame {
9
+ /**
10
+ * Construct a freeze frame
11
+ * @param rootDiv the div that a freeze frame element will be injected into
12
+ */
13
+ constructor(rootDiv) {
14
+ this.freezeFrameHeight = 0;
15
+ this.freezeFrameWidth = 0;
16
+ this.rootDiv = rootDiv;
17
+ // create the overlay
18
+ this.rootElement = document.createElement('div');
19
+ this.rootElement.id = 'freezeFrame';
20
+ this.rootElement.style.display = 'none';
21
+ this.rootElement.style.pointerEvents = 'none';
22
+ this.rootElement.style.position = 'absolute';
23
+ this.rootElement.style.zIndex = '20';
24
+ // create the image place holder
25
+ this.imageElement = document.createElement('img');
26
+ this.imageElement.style.position = 'absolute';
27
+ // append the image into the root element and append the element to the root div
28
+ this.rootElement.appendChild(this.imageElement);
29
+ this.rootDiv.appendChild(this.rootElement);
30
+ }
31
+ /**
32
+ * Set the freeze frame element for showing
33
+ */
34
+ setElementForShow() {
35
+ this.rootElement.style.display = 'block';
36
+ }
37
+ /**
38
+ * Set the freeze frame element for hiding
39
+ */
40
+ setElementForHide() {
41
+ this.rootElement.style.display = 'none';
42
+ }
43
+ /**
44
+ * Update the freeze frames image source
45
+ * @param jpeg - the freeze frame image as a byte array data
46
+ */
47
+ updateImageElementSource(jpeg) {
48
+ const base64 = btoa(jpeg.reduce((data, byte) => data + String.fromCharCode(byte), ''));
49
+ this.imageElement.src = 'data:image/jpeg;base64,' + base64;
50
+ }
51
+ /**
52
+ * Set the dimensions for the freeze frame from the element and resize it
53
+ */
54
+ setDimensionsFromElementAndResize() {
55
+ this.freezeFrameHeight = this.imageElement.naturalHeight;
56
+ this.freezeFrameWidth = this.imageElement.naturalWidth;
57
+ this.resize();
58
+ }
59
+ /**
60
+ * Resize a freeze frame element
61
+ */
62
+ resize() {
63
+ if (this.freezeFrameWidth !== 0 && this.freezeFrameHeight !== 0) {
64
+ let displayWidth = 0;
65
+ let displayHeight = 0;
66
+ let displayTop = 0;
67
+ let displayLeft = 0;
68
+ const parentAspectRatio = this.rootDiv.clientWidth / this.rootDiv.clientHeight;
69
+ const videoAspectRatio = this.freezeFrameWidth / this.freezeFrameHeight;
70
+ if (parentAspectRatio < videoAspectRatio) {
71
+ displayWidth = this.rootDiv.clientWidth;
72
+ displayHeight = Math.floor(this.rootDiv.clientWidth / videoAspectRatio);
73
+ displayTop = Math.floor((this.rootDiv.clientHeight - displayHeight) * 0.5);
74
+ displayLeft = 0;
75
+ }
76
+ else {
77
+ displayWidth = Math.floor(this.rootDiv.clientHeight * videoAspectRatio);
78
+ displayHeight = this.rootDiv.clientHeight;
79
+ displayTop = 0;
80
+ displayLeft = Math.floor((this.rootDiv.clientWidth - displayWidth) * 0.5);
81
+ }
82
+ this.rootElement.style.width = this.rootDiv.offsetWidth + 'px';
83
+ this.rootElement.style.height = this.rootDiv.offsetHeight + 'px';
84
+ this.rootElement.style.left = 0 + 'px';
85
+ this.rootElement.style.top = 0 + 'px';
86
+ this.imageElement.style.width = displayWidth + 'px';
87
+ this.imageElement.style.height = displayHeight + 'px';
88
+ this.imageElement.style.left = displayLeft + 'px';
89
+ this.imageElement.style.top = displayTop + 'px';
90
+ }
91
+ }
92
+ }
93
+ exports.FreezeFrame = FreezeFrame;
94
94
  //# sourceMappingURL=FreezeFrame.js.map
@@ -1,96 +1,96 @@
1
- "use strict";
2
- // Copyright Epic Games, Inc. All Rights Reserved.
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.FreezeFrameController = void 0;
5
- const lib_pixelstreamingcommon_ue5_5_1 = require("@epicgames-ps/lib-pixelstreamingcommon-ue5.5");
6
- const FreezeFrame_1 = require("./FreezeFrame");
7
- /**
8
- * A class for controlling freeze frame functionality
9
- */
10
- class FreezeFrameController {
11
- /**
12
- * Construct a freeze frame controller
13
- * @param rootDiv - the div that a freeze frame element will be injected into
14
- */
15
- constructor(rootDiv) {
16
- this.receiving = false;
17
- this.size = 0;
18
- this.jpeg = undefined;
19
- this.valid = false;
20
- this.freezeFrameDelay = 50;
21
- this.freezeFrame = new FreezeFrame_1.FreezeFrame(rootDiv);
22
- }
23
- /**
24
- * Show the freeze frame if it is valid
25
- */
26
- showFreezeFrame() {
27
- if (this.valid) {
28
- this.freezeFrame.setElementForShow();
29
- }
30
- }
31
- /**
32
- * Hide the freeze frame and set the validity to false
33
- */
34
- hideFreezeFrame() {
35
- this.valid = false;
36
- this.freezeFrame.setElementForHide();
37
- }
38
- /**
39
- * Update the freeze frames image source and load it
40
- * @param jpeg - the freeze frame image as a byte array data
41
- * @param onLoadCallBack - a call back for managing if the play overlay needs to be shown or not
42
- */
43
- updateFreezeFrameAndShow(jpeg, onLoadCallBack) {
44
- this.freezeFrame.updateImageElementSource(jpeg);
45
- this.freezeFrame.imageElement.onload = () => {
46
- this.freezeFrame.setDimensionsFromElementAndResize();
47
- onLoadCallBack();
48
- };
49
- }
50
- /**
51
- * Process the new freeze frame image and update it
52
- * @param view - the freeze frame image as a byte array data
53
- * @param onLoadCallBack - a call back for managing if the play overlay needs to be shown or not
54
- */
55
- processFreezeFrameMessage(view, onLoadCallBack) {
56
- // Reset freeze frame if we got a freeze frame message and we are not "receiving" yet.
57
- if (!this.receiving) {
58
- this.receiving = true;
59
- this.valid = false;
60
- this.size = 0;
61
- this.jpeg = undefined;
62
- }
63
- // Extract total size of freeze frame (across all chunks)
64
- this.size = new DataView(view.slice(1, 5).buffer).getInt32(0, true);
65
- // Get the jpeg part of the payload
66
- const jpegBytes = view.slice(1 + 4);
67
- // Append to existing jpeg that holds the freeze frame
68
- if (this.jpeg) {
69
- const jpeg = new Uint8Array(this.jpeg.length + jpegBytes.length);
70
- jpeg.set(this.jpeg, 0);
71
- jpeg.set(jpegBytes, this.jpeg.length);
72
- this.jpeg = jpeg;
73
- }
74
- // No existing freeze frame jpeg, make one
75
- else {
76
- this.jpeg = jpegBytes;
77
- this.receiving = true;
78
- lib_pixelstreamingcommon_ue5_5_1.Logger.Info(`received first chunk of freeze frame: ${this.jpeg.length}/${this.size}`);
79
- }
80
- // Finished receiving freeze frame, we can show it now
81
- if (this.jpeg.length === this.size) {
82
- this.receiving = false;
83
- this.valid = true;
84
- lib_pixelstreamingcommon_ue5_5_1.Logger.Info(`received complete freeze frame ${this.size}`);
85
- this.updateFreezeFrameAndShow(this.jpeg, onLoadCallBack);
86
- }
87
- // We received more data than the freeze frame payload message indicate (this is an error)
88
- else if (this.jpeg.length > this.size) {
89
- lib_pixelstreamingcommon_ue5_5_1.Logger.Error(`received bigger freeze frame than advertised: ${this.jpeg.length}/${this.size}`);
90
- this.jpeg = undefined;
91
- this.receiving = false;
92
- }
93
- }
94
- }
95
- exports.FreezeFrameController = FreezeFrameController;
1
+ "use strict";
2
+ // Copyright Epic Games, Inc. All Rights Reserved.
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.FreezeFrameController = void 0;
5
+ const lib_pixelstreamingcommon_ue5_5_1 = require("@epicgames-ps/lib-pixelstreamingcommon-ue5.5");
6
+ const FreezeFrame_1 = require("./FreezeFrame");
7
+ /**
8
+ * A class for controlling freeze frame functionality
9
+ */
10
+ class FreezeFrameController {
11
+ /**
12
+ * Construct a freeze frame controller
13
+ * @param rootDiv - the div that a freeze frame element will be injected into
14
+ */
15
+ constructor(rootDiv) {
16
+ this.receiving = false;
17
+ this.size = 0;
18
+ this.jpeg = undefined;
19
+ this.valid = false;
20
+ this.freezeFrameDelay = 50;
21
+ this.freezeFrame = new FreezeFrame_1.FreezeFrame(rootDiv);
22
+ }
23
+ /**
24
+ * Show the freeze frame if it is valid
25
+ */
26
+ showFreezeFrame() {
27
+ if (this.valid) {
28
+ this.freezeFrame.setElementForShow();
29
+ }
30
+ }
31
+ /**
32
+ * Hide the freeze frame and set the validity to false
33
+ */
34
+ hideFreezeFrame() {
35
+ this.valid = false;
36
+ this.freezeFrame.setElementForHide();
37
+ }
38
+ /**
39
+ * Update the freeze frames image source and load it
40
+ * @param jpeg - the freeze frame image as a byte array data
41
+ * @param onLoadCallBack - a call back for managing if the play overlay needs to be shown or not
42
+ */
43
+ updateFreezeFrameAndShow(jpeg, onLoadCallBack) {
44
+ this.freezeFrame.updateImageElementSource(jpeg);
45
+ this.freezeFrame.imageElement.onload = () => {
46
+ this.freezeFrame.setDimensionsFromElementAndResize();
47
+ onLoadCallBack();
48
+ };
49
+ }
50
+ /**
51
+ * Process the new freeze frame image and update it
52
+ * @param view - the freeze frame image as a byte array data
53
+ * @param onLoadCallBack - a call back for managing if the play overlay needs to be shown or not
54
+ */
55
+ processFreezeFrameMessage(view, onLoadCallBack) {
56
+ // Reset freeze frame if we got a freeze frame message and we are not "receiving" yet.
57
+ if (!this.receiving) {
58
+ this.receiving = true;
59
+ this.valid = false;
60
+ this.size = 0;
61
+ this.jpeg = undefined;
62
+ }
63
+ // Extract total size of freeze frame (across all chunks)
64
+ this.size = new DataView(view.slice(1, 5).buffer).getInt32(0, true);
65
+ // Get the jpeg part of the payload
66
+ const jpegBytes = view.slice(1 + 4);
67
+ // Append to existing jpeg that holds the freeze frame
68
+ if (this.jpeg) {
69
+ const jpeg = new Uint8Array(this.jpeg.length + jpegBytes.length);
70
+ jpeg.set(this.jpeg, 0);
71
+ jpeg.set(jpegBytes, this.jpeg.length);
72
+ this.jpeg = jpeg;
73
+ }
74
+ // No existing freeze frame jpeg, make one
75
+ else {
76
+ this.jpeg = jpegBytes;
77
+ this.receiving = true;
78
+ lib_pixelstreamingcommon_ue5_5_1.Logger.Info(`received first chunk of freeze frame: ${this.jpeg.length}/${this.size}`);
79
+ }
80
+ // Finished receiving freeze frame, we can show it now
81
+ if (this.jpeg.length === this.size) {
82
+ this.receiving = false;
83
+ this.valid = true;
84
+ lib_pixelstreamingcommon_ue5_5_1.Logger.Info(`received complete freeze frame ${this.size}`);
85
+ this.updateFreezeFrameAndShow(this.jpeg, onLoadCallBack);
86
+ }
87
+ // We received more data than the freeze frame payload message indicate (this is an error)
88
+ else if (this.jpeg.length > this.size) {
89
+ lib_pixelstreamingcommon_ue5_5_1.Logger.Error(`received bigger freeze frame than advertised: ${this.jpeg.length}/${this.size}`);
90
+ this.jpeg = undefined;
91
+ this.receiving = false;
92
+ }
93
+ }
94
+ }
95
+ exports.FreezeFrameController = FreezeFrameController;
96
96
  //# sourceMappingURL=FreezeFrameController.js.map