@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.
Files changed (172) 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/TouchController.js.map +1 -1
  29. package/dist/commonjs/Inputs/TouchControllerFake.js +91 -91
  30. package/dist/commonjs/Inputs/XRGamepadController.js +124 -124
  31. package/dist/commonjs/PeerConnectionController/AggregatedStats.js +252 -252
  32. package/dist/commonjs/PeerConnectionController/CandidatePairStats.js +10 -10
  33. package/dist/commonjs/PeerConnectionController/CandidateStat.js +10 -10
  34. package/dist/commonjs/PeerConnectionController/CodecStats.js +10 -10
  35. package/dist/commonjs/PeerConnectionController/DataChannelStats.js +10 -10
  36. package/dist/commonjs/PeerConnectionController/InboundRTPStats.js +22 -22
  37. package/dist/commonjs/PeerConnectionController/InboundTrackStats.js +10 -10
  38. package/dist/commonjs/PeerConnectionController/OutBoundRTPStats.js +16 -16
  39. package/dist/commonjs/PeerConnectionController/PeerConnectionController.js +584 -584
  40. package/dist/commonjs/PeerConnectionController/SessionStats.js +10 -10
  41. package/dist/commonjs/PeerConnectionController/StreamStats.js +10 -10
  42. package/dist/commonjs/PixelStreaming/PixelStreaming.js +607 -607
  43. package/dist/commonjs/UI/OnScreenKeyboard.js +82 -82
  44. package/dist/commonjs/UeInstanceMessage/ResponseController.js +38 -38
  45. package/dist/commonjs/UeInstanceMessage/SendMessageController.js +120 -120
  46. package/dist/commonjs/UeInstanceMessage/StreamMessageController.js +210 -210
  47. package/dist/commonjs/UeInstanceMessage/ToStreamerMessagesController.js +49 -49
  48. package/dist/commonjs/Util/EventEmitter.js +386 -386
  49. package/dist/commonjs/Util/FileUtil.js +108 -108
  50. package/dist/commonjs/Util/IURLSearchParams.js +25 -25
  51. package/dist/commonjs/Util/InputCoordTranslator.js +49 -49
  52. package/dist/commonjs/Util/RTCUtils.js +40 -40
  53. package/dist/commonjs/VideoPlayer/StreamController.js +67 -67
  54. package/dist/commonjs/VideoPlayer/VideoPlayer.js +177 -177
  55. package/dist/commonjs/WebRtcPlayer/WebRtcPlayerController.js +1221 -1221
  56. package/dist/commonjs/WebXR/WebXRController.js +335 -335
  57. package/dist/commonjs/pixelstreamingfrontend.js +70 -70
  58. package/dist/esm/AFK/AFKController.js +105 -105
  59. package/dist/esm/Config/Config.js +551 -551
  60. package/dist/esm/Config/SettingBase.js +94 -94
  61. package/dist/esm/Config/SettingFlag.js +45 -45
  62. package/dist/esm/Config/SettingNumber.js +79 -79
  63. package/dist/esm/Config/SettingOption.js +80 -80
  64. package/dist/esm/Config/SettingText.js +38 -38
  65. package/dist/esm/DataChannel/DataChannelController.js +102 -102
  66. package/dist/esm/DataChannel/DataChannelLatencyTestController.js +90 -90
  67. package/dist/esm/DataChannel/DataChannelLatencyTestResults.js +14 -14
  68. package/dist/esm/DataChannel/DataChannelSender.js +39 -39
  69. package/dist/esm/DataChannel/InitialSettings.js +34 -34
  70. package/dist/esm/DataChannel/LatencyTestResults.js +56 -56
  71. package/dist/esm/FreezeFrame/FreezeFrame.js +89 -89
  72. package/dist/esm/FreezeFrame/FreezeFrameController.js +91 -91
  73. package/dist/esm/Inputs/GamepadController.js +184 -184
  74. package/dist/esm/Inputs/GamepadTypes.js +17 -17
  75. package/dist/esm/Inputs/IInputController.js +1 -1
  76. package/dist/esm/Inputs/InputClassesFactory.js +91 -91
  77. package/dist/esm/Inputs/KeyCodes.js +109 -109
  78. package/dist/esm/Inputs/KeyboardController.js +133 -133
  79. package/dist/esm/Inputs/MouseButtons.js +23 -23
  80. package/dist/esm/Inputs/MouseController.js +93 -93
  81. package/dist/esm/Inputs/MouseControllerHovering.js +89 -89
  82. package/dist/esm/Inputs/MouseControllerLocked.js +149 -149
  83. package/dist/esm/Inputs/SpecialKeyCodes.js +15 -15
  84. package/dist/esm/Inputs/TouchController.js +119 -119
  85. package/dist/esm/Inputs/TouchController.js.map +1 -1
  86. package/dist/esm/Inputs/TouchControllerFake.js +87 -87
  87. package/dist/esm/Inputs/XRGamepadController.js +120 -120
  88. package/dist/esm/PeerConnectionController/AggregatedStats.js +248 -248
  89. package/dist/esm/PeerConnectionController/CandidatePairStats.js +6 -6
  90. package/dist/esm/PeerConnectionController/CandidateStat.js +6 -6
  91. package/dist/esm/PeerConnectionController/CodecStats.js +6 -6
  92. package/dist/esm/PeerConnectionController/DataChannelStats.js +6 -6
  93. package/dist/esm/PeerConnectionController/InboundRTPStats.js +16 -16
  94. package/dist/esm/PeerConnectionController/InboundTrackStats.js +6 -6
  95. package/dist/esm/PeerConnectionController/OutBoundRTPStats.js +11 -11
  96. package/dist/esm/PeerConnectionController/PeerConnectionController.js +580 -580
  97. package/dist/esm/PeerConnectionController/SessionStats.js +6 -6
  98. package/dist/esm/PeerConnectionController/StreamStats.js +6 -6
  99. package/dist/esm/PixelStreaming/PixelStreaming.js +603 -603
  100. package/dist/esm/UI/OnScreenKeyboard.js +78 -78
  101. package/dist/esm/UeInstanceMessage/ResponseController.js +34 -34
  102. package/dist/esm/UeInstanceMessage/SendMessageController.js +116 -116
  103. package/dist/esm/UeInstanceMessage/StreamMessageController.js +205 -205
  104. package/dist/esm/UeInstanceMessage/ToStreamerMessagesController.js +45 -45
  105. package/dist/esm/Util/EventEmitter.js +345 -345
  106. package/dist/esm/Util/FileUtil.js +103 -103
  107. package/dist/esm/Util/IURLSearchParams.js +21 -21
  108. package/dist/esm/Util/InputCoordTranslator.js +45 -45
  109. package/dist/esm/Util/RTCUtils.js +36 -36
  110. package/dist/esm/VideoPlayer/StreamController.js +63 -63
  111. package/dist/esm/VideoPlayer/VideoPlayer.js +173 -173
  112. package/dist/esm/WebRtcPlayer/WebRtcPlayerController.js +1217 -1217
  113. package/dist/esm/WebXR/WebXRController.js +331 -331
  114. package/dist/esm/pixelstreamingfrontend.js +24 -24
  115. package/dist/types/AFK/AFKController.d.ts +38 -38
  116. package/dist/types/Config/Config.d.ts +220 -220
  117. package/dist/types/Config/SettingBase.d.ts +43 -43
  118. package/dist/types/Config/SettingFlag.d.ts +24 -24
  119. package/dist/types/Config/SettingNumber.d.ts +41 -41
  120. package/dist/types/Config/SettingOption.d.ts +41 -41
  121. package/dist/types/Config/SettingText.d.ts +21 -21
  122. package/dist/types/DataChannel/DataChannelController.d.ts +59 -59
  123. package/dist/types/DataChannel/DataChannelLatencyTestController.d.ts +25 -25
  124. package/dist/types/DataChannel/DataChannelLatencyTestResults.d.ts +46 -46
  125. package/dist/types/DataChannel/DataChannelSender.d.ts +21 -21
  126. package/dist/types/DataChannel/InitialSettings.d.ts +44 -44
  127. package/dist/types/DataChannel/LatencyTestResults.d.ts +31 -31
  128. package/dist/types/FreezeFrame/FreezeFrame.d.ts +36 -36
  129. package/dist/types/FreezeFrame/FreezeFrameController.d.ts +37 -37
  130. package/dist/types/Inputs/GamepadController.d.ts +61 -61
  131. package/dist/types/Inputs/GamepadTypes.d.ts +15 -15
  132. package/dist/types/Inputs/IInputController.d.ts +16 -16
  133. package/dist/types/Inputs/InputClassesFactory.d.ts +53 -53
  134. package/dist/types/Inputs/KeyCodes.d.ts +5 -5
  135. package/dist/types/Inputs/KeyboardController.d.ts +34 -34
  136. package/dist/types/Inputs/MouseButtons.d.ts +22 -22
  137. package/dist/types/Inputs/MouseController.d.ts +40 -40
  138. package/dist/types/Inputs/MouseControllerHovering.d.ts +26 -26
  139. package/dist/types/Inputs/MouseControllerLocked.d.ts +31 -31
  140. package/dist/types/Inputs/SpecialKeyCodes.d.ts +14 -14
  141. package/dist/types/Inputs/TouchController.d.ts +28 -28
  142. package/dist/types/Inputs/TouchControllerFake.d.ts +29 -29
  143. package/dist/types/Inputs/XRGamepadController.d.ts +15 -15
  144. package/dist/types/PeerConnectionController/AggregatedStats.d.ts +82 -82
  145. package/dist/types/PeerConnectionController/CandidatePairStats.d.ts +22 -22
  146. package/dist/types/PeerConnectionController/CandidateStat.d.ts +13 -13
  147. package/dist/types/PeerConnectionController/CodecStats.d.ts +14 -14
  148. package/dist/types/PeerConnectionController/DataChannelStats.d.ts +15 -15
  149. package/dist/types/PeerConnectionController/InboundRTPStats.d.ts +141 -141
  150. package/dist/types/PeerConnectionController/InboundTrackStats.d.ts +32 -32
  151. package/dist/types/PeerConnectionController/OutBoundRTPStats.d.ts +23 -23
  152. package/dist/types/PeerConnectionController/PeerConnectionController.d.ts +143 -143
  153. package/dist/types/PeerConnectionController/SessionStats.d.ts +8 -8
  154. package/dist/types/PeerConnectionController/StreamStats.d.ts +9 -9
  155. package/dist/types/PixelStreaming/PixelStreaming.d.ts +271 -271
  156. package/dist/types/UI/OnScreenKeyboard.d.ts +30 -30
  157. package/dist/types/UeInstanceMessage/ResponseController.d.ts +19 -19
  158. package/dist/types/UeInstanceMessage/SendMessageController.d.ts +18 -18
  159. package/dist/types/UeInstanceMessage/StreamMessageController.d.ts +29 -29
  160. package/dist/types/UeInstanceMessage/ToStreamerMessagesController.d.ts +32 -32
  161. package/dist/types/Util/EventEmitter.d.ts +429 -429
  162. package/dist/types/Util/FileUtil.d.ts +32 -32
  163. package/dist/types/Util/IURLSearchParams.d.ts +9 -9
  164. package/dist/types/Util/InputCoordTranslator.d.ts +29 -29
  165. package/dist/types/Util/RTCUtils.d.ts +8 -8
  166. package/dist/types/VideoPlayer/StreamController.d.ts +22 -22
  167. package/dist/types/VideoPlayer/VideoPlayer.d.ts +78 -78
  168. package/dist/types/WebRtcPlayer/WebRtcPlayerController.d.ts +379 -379
  169. package/dist/types/WebXR/WebXRController.d.ts +42 -42
  170. package/dist/types/pixelstreamingfrontend.d.ts +23 -23
  171. package/package.json +45 -45
  172. package/src/Inputs/TouchController.ts +3 -3
@@ -1,253 +1,253 @@
1
- "use strict";
2
- // Copyright Epic Games, Inc. All Rights Reserved.
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.AggregatedStats = void 0;
5
- const InboundRTPStats_1 = require("./InboundRTPStats");
6
- const DataChannelStats_1 = require("./DataChannelStats");
7
- const CandidateStat_1 = require("./CandidateStat");
8
- const OutBoundRTPStats_1 = require("./OutBoundRTPStats");
9
- const SessionStats_1 = require("./SessionStats");
10
- const StreamStats_1 = require("./StreamStats");
11
- const lib_pixelstreamingcommon_ue5_5_1 = require("@epicgames-ps/lib-pixelstreamingcommon-ue5.5");
12
- class AggregatedStats {
13
- constructor() {
14
- this.inboundVideoStats = new InboundRTPStats_1.InboundVideoStats();
15
- this.inboundAudioStats = new InboundRTPStats_1.InboundAudioStats();
16
- this.DataChannelStats = new DataChannelStats_1.DataChannelStats();
17
- this.outBoundVideoStats = new OutBoundRTPStats_1.OutBoundVideoStats();
18
- this.sessionStats = new SessionStats_1.SessionStats();
19
- this.streamStats = new StreamStats_1.StreamStats();
20
- this.codecs = new Map();
21
- }
22
- /**
23
- * Gather all the information from the RTC Peer Connection Report
24
- * @param rtcStatsReport - RTC Stats Report
25
- */
26
- processStats(rtcStatsReport) {
27
- this.localCandidates = new Array();
28
- this.remoteCandidates = new Array();
29
- this.candidatePairs = new Array();
30
- rtcStatsReport.forEach((stat) => {
31
- const type = stat.type;
32
- switch (type) {
33
- case 'candidate-pair':
34
- this.handleCandidatePair(stat);
35
- break;
36
- case 'certificate':
37
- break;
38
- case 'codec':
39
- this.handleCodec(stat);
40
- break;
41
- case 'data-channel':
42
- this.handleDataChannel(stat);
43
- break;
44
- case 'inbound-rtp':
45
- this.handleInBoundRTP(stat);
46
- break;
47
- case 'local-candidate':
48
- this.handleLocalCandidate(stat);
49
- break;
50
- case 'media-source':
51
- break;
52
- case 'media-playout':
53
- break;
54
- case 'outbound-rtp':
55
- break;
56
- case 'peer-connection':
57
- break;
58
- case 'remote-candidate':
59
- this.handleRemoteCandidate(stat);
60
- break;
61
- case 'remote-inbound-rtp':
62
- break;
63
- case 'remote-outbound-rtp':
64
- this.handleRemoteOutBound(stat);
65
- break;
66
- case 'track':
67
- this.handleTrack(stat);
68
- break;
69
- case 'transport':
70
- this.handleTransport(stat);
71
- break;
72
- case 'stream':
73
- this.handleStream(stat);
74
- break;
75
- default:
76
- lib_pixelstreamingcommon_ue5_5_1.Logger.Error('unhandled Stat Type');
77
- lib_pixelstreamingcommon_ue5_5_1.Logger.Info(stat);
78
- break;
79
- }
80
- });
81
- }
82
- /**
83
- * Process stream stats data from webrtc
84
- *
85
- * @param stat - the stats coming in from webrtc
86
- */
87
- handleStream(stat) {
88
- this.streamStats = stat;
89
- }
90
- /**
91
- * Process the Ice Candidate Pair Data
92
- * @param stat - the stats coming in from ice candidates
93
- */
94
- handleCandidatePair(stat) {
95
- // Add the candidate pair to the candidate pair array
96
- this.candidatePairs.push(stat);
97
- }
98
- /**
99
- * Process the Data Channel Data
100
- * @param stat - the stats coming in from the data channel
101
- */
102
- handleDataChannel(stat) {
103
- this.DataChannelStats.bytesReceived = stat.bytesReceived;
104
- this.DataChannelStats.bytesSent = stat.bytesSent;
105
- this.DataChannelStats.dataChannelIdentifier = stat.dataChannelIdentifier;
106
- this.DataChannelStats.id = stat.id;
107
- this.DataChannelStats.label = stat.label;
108
- this.DataChannelStats.messagesReceived = stat.messagesReceived;
109
- this.DataChannelStats.messagesSent = stat.messagesSent;
110
- this.DataChannelStats.protocol = stat.protocol;
111
- this.DataChannelStats.state = stat.state;
112
- this.DataChannelStats.timestamp = stat.timestamp;
113
- }
114
- /**
115
- * Process the Local Ice Candidate Data
116
- * @param stat - local stats
117
- */
118
- handleLocalCandidate(stat) {
119
- const localCandidate = new CandidateStat_1.CandidateStat();
120
- localCandidate.label = 'local-candidate';
121
- localCandidate.address = stat.address;
122
- localCandidate.port = stat.port;
123
- localCandidate.protocol = stat.protocol;
124
- localCandidate.candidateType = stat.candidateType;
125
- localCandidate.id = stat.id;
126
- localCandidate.relayProtocol = stat.relayProtocol;
127
- localCandidate.transportId = stat.transportId;
128
- this.localCandidates.push(localCandidate);
129
- }
130
- /**
131
- * Process the Remote Ice Candidate Data
132
- * @param stat - ice candidate stats
133
- */
134
- handleRemoteCandidate(stat) {
135
- const RemoteCandidate = new CandidateStat_1.CandidateStat();
136
- RemoteCandidate.label = 'remote-candidate';
137
- RemoteCandidate.address = stat.address;
138
- RemoteCandidate.port = stat.port;
139
- RemoteCandidate.protocol = stat.protocol;
140
- RemoteCandidate.id = stat.id;
141
- RemoteCandidate.candidateType = stat.candidateType;
142
- RemoteCandidate.relayProtocol = stat.relayProtocol;
143
- RemoteCandidate.transportId = stat.transportId;
144
- this.remoteCandidates.push(RemoteCandidate);
145
- }
146
- /**
147
- * Process the Inbound RTP Audio and Video Data
148
- * @param stat - inbound rtp stats
149
- */
150
- handleInBoundRTP(stat) {
151
- switch (stat.kind) {
152
- case 'video':
153
- // Calculate bitrate between stat updates
154
- if (stat.bytesReceived > this.inboundVideoStats.bytesReceived &&
155
- stat.timestamp > this.inboundVideoStats.timestamp) {
156
- this.inboundVideoStats.bitrate =
157
- (8 * (stat.bytesReceived - this.inboundVideoStats.bytesReceived)) /
158
- (stat.timestamp - this.inboundVideoStats.timestamp);
159
- this.inboundVideoStats.bitrate = Math.floor(this.inboundVideoStats.bitrate);
160
- }
161
- // Copy members from stat into `this.inboundVideoStats`
162
- for (const key in stat) {
163
- this.inboundVideoStats[key] = stat[key];
164
- }
165
- break;
166
- case 'audio':
167
- if (stat.bytesReceived > this.inboundAudioStats.bytesReceived &&
168
- stat.timestamp > this.inboundAudioStats.timestamp) {
169
- this.inboundAudioStats.bitrate =
170
- (8 * (stat.bytesReceived - this.inboundAudioStats.bytesReceived)) /
171
- (stat.timestamp - this.inboundAudioStats.timestamp);
172
- this.inboundAudioStats.bitrate = Math.floor(this.inboundAudioStats.bitrate);
173
- }
174
- // Copy members from stat into `this.inboundAudioStats`
175
- for (const key in stat) {
176
- this.inboundAudioStats[key] = stat[key];
177
- }
178
- break;
179
- default:
180
- lib_pixelstreamingcommon_ue5_5_1.Logger.Error(`Kind should be audio or video, we got ${stat.kind} - that's unsupported.`);
181
- break;
182
- }
183
- }
184
- /**
185
- * Process the outbound RTP Audio and Video Data
186
- * @param stat - remote outbound stats
187
- */
188
- handleRemoteOutBound(stat) {
189
- switch (stat.kind) {
190
- case 'video':
191
- this.outBoundVideoStats.bytesSent = stat.bytesSent;
192
- this.outBoundVideoStats.id = stat.id;
193
- this.outBoundVideoStats.localId = stat.localId;
194
- this.outBoundVideoStats.packetsSent = stat.packetsSent;
195
- this.outBoundVideoStats.remoteTimestamp = stat.remoteTimestamp;
196
- this.outBoundVideoStats.timestamp = stat.timestamp;
197
- break;
198
- case 'audio':
199
- break;
200
- default:
201
- break;
202
- }
203
- }
204
- /**
205
- * Process the Inbound Video Track Data
206
- * @param stat - video track stats
207
- */
208
- handleTrack(stat) {
209
- // we only want to extract stats from the video track
210
- if (stat.type === 'track' && (stat.trackIdentifier === 'video_label' || stat.kind === 'video')) {
211
- this.inboundVideoStats.framesDropped = stat.framesDropped;
212
- this.inboundVideoStats.framesReceived = stat.framesReceived;
213
- this.inboundVideoStats.frameHeight = stat.frameHeight;
214
- this.inboundVideoStats.frameWidth = stat.frameWidth;
215
- }
216
- }
217
- handleTransport(stat) {
218
- this.transportStats = stat;
219
- }
220
- handleCodec(stat) {
221
- const codecId = stat.id;
222
- this.codecs.set(codecId, stat);
223
- }
224
- handleSessionStatistics(videoStartTime, inputController, videoEncoderAvgQP) {
225
- const deltaTime = Date.now() - videoStartTime;
226
- this.sessionStats.runTime = new Date(deltaTime).toISOString().substr(11, 8).toString();
227
- const controlsStreamInput = inputController === null ? 'Not sent yet' : inputController ? 'true' : 'false';
228
- this.sessionStats.controlsStreamInput = controlsStreamInput;
229
- this.sessionStats.videoEncoderAvgQP = videoEncoderAvgQP;
230
- }
231
- /**
232
- * Check if a value coming in from our stats is actually a number
233
- * @param value - the number to be checked
234
- */
235
- isNumber(value) {
236
- return typeof value === 'number' && isFinite(value);
237
- }
238
- /**
239
- * Helper function to return the active candidate pair
240
- * @returns The candidate pair that is currently receiving data
241
- */
242
- getActiveCandidatePair() {
243
- // Check if the RTCTransport stat is not undefined
244
- if (this.transportStats) {
245
- // Return the candidate pair that matches the transport candidate pair id
246
- return this.candidatePairs.find((candidatePair) => candidatePair.id === this.transportStats.selectedCandidatePairId, null);
247
- }
248
- // Fall back to the selected candidate pair
249
- return this.candidatePairs.find((candidatePair) => candidatePair.selected, null);
250
- }
251
- }
252
- exports.AggregatedStats = AggregatedStats;
1
+ "use strict";
2
+ // Copyright Epic Games, Inc. All Rights Reserved.
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.AggregatedStats = void 0;
5
+ const InboundRTPStats_1 = require("./InboundRTPStats");
6
+ const DataChannelStats_1 = require("./DataChannelStats");
7
+ const CandidateStat_1 = require("./CandidateStat");
8
+ const OutBoundRTPStats_1 = require("./OutBoundRTPStats");
9
+ const SessionStats_1 = require("./SessionStats");
10
+ const StreamStats_1 = require("./StreamStats");
11
+ const lib_pixelstreamingcommon_ue5_5_1 = require("@epicgames-ps/lib-pixelstreamingcommon-ue5.5");
12
+ class AggregatedStats {
13
+ constructor() {
14
+ this.inboundVideoStats = new InboundRTPStats_1.InboundVideoStats();
15
+ this.inboundAudioStats = new InboundRTPStats_1.InboundAudioStats();
16
+ this.DataChannelStats = new DataChannelStats_1.DataChannelStats();
17
+ this.outBoundVideoStats = new OutBoundRTPStats_1.OutBoundVideoStats();
18
+ this.sessionStats = new SessionStats_1.SessionStats();
19
+ this.streamStats = new StreamStats_1.StreamStats();
20
+ this.codecs = new Map();
21
+ }
22
+ /**
23
+ * Gather all the information from the RTC Peer Connection Report
24
+ * @param rtcStatsReport - RTC Stats Report
25
+ */
26
+ processStats(rtcStatsReport) {
27
+ this.localCandidates = new Array();
28
+ this.remoteCandidates = new Array();
29
+ this.candidatePairs = new Array();
30
+ rtcStatsReport.forEach((stat) => {
31
+ const type = stat.type;
32
+ switch (type) {
33
+ case 'candidate-pair':
34
+ this.handleCandidatePair(stat);
35
+ break;
36
+ case 'certificate':
37
+ break;
38
+ case 'codec':
39
+ this.handleCodec(stat);
40
+ break;
41
+ case 'data-channel':
42
+ this.handleDataChannel(stat);
43
+ break;
44
+ case 'inbound-rtp':
45
+ this.handleInBoundRTP(stat);
46
+ break;
47
+ case 'local-candidate':
48
+ this.handleLocalCandidate(stat);
49
+ break;
50
+ case 'media-source':
51
+ break;
52
+ case 'media-playout':
53
+ break;
54
+ case 'outbound-rtp':
55
+ break;
56
+ case 'peer-connection':
57
+ break;
58
+ case 'remote-candidate':
59
+ this.handleRemoteCandidate(stat);
60
+ break;
61
+ case 'remote-inbound-rtp':
62
+ break;
63
+ case 'remote-outbound-rtp':
64
+ this.handleRemoteOutBound(stat);
65
+ break;
66
+ case 'track':
67
+ this.handleTrack(stat);
68
+ break;
69
+ case 'transport':
70
+ this.handleTransport(stat);
71
+ break;
72
+ case 'stream':
73
+ this.handleStream(stat);
74
+ break;
75
+ default:
76
+ lib_pixelstreamingcommon_ue5_5_1.Logger.Error('unhandled Stat Type');
77
+ lib_pixelstreamingcommon_ue5_5_1.Logger.Info(stat);
78
+ break;
79
+ }
80
+ });
81
+ }
82
+ /**
83
+ * Process stream stats data from webrtc
84
+ *
85
+ * @param stat - the stats coming in from webrtc
86
+ */
87
+ handleStream(stat) {
88
+ this.streamStats = stat;
89
+ }
90
+ /**
91
+ * Process the Ice Candidate Pair Data
92
+ * @param stat - the stats coming in from ice candidates
93
+ */
94
+ handleCandidatePair(stat) {
95
+ // Add the candidate pair to the candidate pair array
96
+ this.candidatePairs.push(stat);
97
+ }
98
+ /**
99
+ * Process the Data Channel Data
100
+ * @param stat - the stats coming in from the data channel
101
+ */
102
+ handleDataChannel(stat) {
103
+ this.DataChannelStats.bytesReceived = stat.bytesReceived;
104
+ this.DataChannelStats.bytesSent = stat.bytesSent;
105
+ this.DataChannelStats.dataChannelIdentifier = stat.dataChannelIdentifier;
106
+ this.DataChannelStats.id = stat.id;
107
+ this.DataChannelStats.label = stat.label;
108
+ this.DataChannelStats.messagesReceived = stat.messagesReceived;
109
+ this.DataChannelStats.messagesSent = stat.messagesSent;
110
+ this.DataChannelStats.protocol = stat.protocol;
111
+ this.DataChannelStats.state = stat.state;
112
+ this.DataChannelStats.timestamp = stat.timestamp;
113
+ }
114
+ /**
115
+ * Process the Local Ice Candidate Data
116
+ * @param stat - local stats
117
+ */
118
+ handleLocalCandidate(stat) {
119
+ const localCandidate = new CandidateStat_1.CandidateStat();
120
+ localCandidate.label = 'local-candidate';
121
+ localCandidate.address = stat.address;
122
+ localCandidate.port = stat.port;
123
+ localCandidate.protocol = stat.protocol;
124
+ localCandidate.candidateType = stat.candidateType;
125
+ localCandidate.id = stat.id;
126
+ localCandidate.relayProtocol = stat.relayProtocol;
127
+ localCandidate.transportId = stat.transportId;
128
+ this.localCandidates.push(localCandidate);
129
+ }
130
+ /**
131
+ * Process the Remote Ice Candidate Data
132
+ * @param stat - ice candidate stats
133
+ */
134
+ handleRemoteCandidate(stat) {
135
+ const RemoteCandidate = new CandidateStat_1.CandidateStat();
136
+ RemoteCandidate.label = 'remote-candidate';
137
+ RemoteCandidate.address = stat.address;
138
+ RemoteCandidate.port = stat.port;
139
+ RemoteCandidate.protocol = stat.protocol;
140
+ RemoteCandidate.id = stat.id;
141
+ RemoteCandidate.candidateType = stat.candidateType;
142
+ RemoteCandidate.relayProtocol = stat.relayProtocol;
143
+ RemoteCandidate.transportId = stat.transportId;
144
+ this.remoteCandidates.push(RemoteCandidate);
145
+ }
146
+ /**
147
+ * Process the Inbound RTP Audio and Video Data
148
+ * @param stat - inbound rtp stats
149
+ */
150
+ handleInBoundRTP(stat) {
151
+ switch (stat.kind) {
152
+ case 'video':
153
+ // Calculate bitrate between stat updates
154
+ if (stat.bytesReceived > this.inboundVideoStats.bytesReceived &&
155
+ stat.timestamp > this.inboundVideoStats.timestamp) {
156
+ this.inboundVideoStats.bitrate =
157
+ (8 * (stat.bytesReceived - this.inboundVideoStats.bytesReceived)) /
158
+ (stat.timestamp - this.inboundVideoStats.timestamp);
159
+ this.inboundVideoStats.bitrate = Math.floor(this.inboundVideoStats.bitrate);
160
+ }
161
+ // Copy members from stat into `this.inboundVideoStats`
162
+ for (const key in stat) {
163
+ this.inboundVideoStats[key] = stat[key];
164
+ }
165
+ break;
166
+ case 'audio':
167
+ if (stat.bytesReceived > this.inboundAudioStats.bytesReceived &&
168
+ stat.timestamp > this.inboundAudioStats.timestamp) {
169
+ this.inboundAudioStats.bitrate =
170
+ (8 * (stat.bytesReceived - this.inboundAudioStats.bytesReceived)) /
171
+ (stat.timestamp - this.inboundAudioStats.timestamp);
172
+ this.inboundAudioStats.bitrate = Math.floor(this.inboundAudioStats.bitrate);
173
+ }
174
+ // Copy members from stat into `this.inboundAudioStats`
175
+ for (const key in stat) {
176
+ this.inboundAudioStats[key] = stat[key];
177
+ }
178
+ break;
179
+ default:
180
+ lib_pixelstreamingcommon_ue5_5_1.Logger.Error(`Kind should be audio or video, we got ${stat.kind} - that's unsupported.`);
181
+ break;
182
+ }
183
+ }
184
+ /**
185
+ * Process the outbound RTP Audio and Video Data
186
+ * @param stat - remote outbound stats
187
+ */
188
+ handleRemoteOutBound(stat) {
189
+ switch (stat.kind) {
190
+ case 'video':
191
+ this.outBoundVideoStats.bytesSent = stat.bytesSent;
192
+ this.outBoundVideoStats.id = stat.id;
193
+ this.outBoundVideoStats.localId = stat.localId;
194
+ this.outBoundVideoStats.packetsSent = stat.packetsSent;
195
+ this.outBoundVideoStats.remoteTimestamp = stat.remoteTimestamp;
196
+ this.outBoundVideoStats.timestamp = stat.timestamp;
197
+ break;
198
+ case 'audio':
199
+ break;
200
+ default:
201
+ break;
202
+ }
203
+ }
204
+ /**
205
+ * Process the Inbound Video Track Data
206
+ * @param stat - video track stats
207
+ */
208
+ handleTrack(stat) {
209
+ // we only want to extract stats from the video track
210
+ if (stat.type === 'track' && (stat.trackIdentifier === 'video_label' || stat.kind === 'video')) {
211
+ this.inboundVideoStats.framesDropped = stat.framesDropped;
212
+ this.inboundVideoStats.framesReceived = stat.framesReceived;
213
+ this.inboundVideoStats.frameHeight = stat.frameHeight;
214
+ this.inboundVideoStats.frameWidth = stat.frameWidth;
215
+ }
216
+ }
217
+ handleTransport(stat) {
218
+ this.transportStats = stat;
219
+ }
220
+ handleCodec(stat) {
221
+ const codecId = stat.id;
222
+ this.codecs.set(codecId, stat);
223
+ }
224
+ handleSessionStatistics(videoStartTime, inputController, videoEncoderAvgQP) {
225
+ const deltaTime = Date.now() - videoStartTime;
226
+ this.sessionStats.runTime = new Date(deltaTime).toISOString().substr(11, 8).toString();
227
+ const controlsStreamInput = inputController === null ? 'Not sent yet' : inputController ? 'true' : 'false';
228
+ this.sessionStats.controlsStreamInput = controlsStreamInput;
229
+ this.sessionStats.videoEncoderAvgQP = videoEncoderAvgQP;
230
+ }
231
+ /**
232
+ * Check if a value coming in from our stats is actually a number
233
+ * @param value - the number to be checked
234
+ */
235
+ isNumber(value) {
236
+ return typeof value === 'number' && isFinite(value);
237
+ }
238
+ /**
239
+ * Helper function to return the active candidate pair
240
+ * @returns The candidate pair that is currently receiving data
241
+ */
242
+ getActiveCandidatePair() {
243
+ // Check if the RTCTransport stat is not undefined
244
+ if (this.transportStats) {
245
+ // Return the candidate pair that matches the transport candidate pair id
246
+ return this.candidatePairs.find((candidatePair) => candidatePair.id === this.transportStats.selectedCandidatePairId, null);
247
+ }
248
+ // Fall back to the selected candidate pair
249
+ return this.candidatePairs.find((candidatePair) => candidatePair.selected, null);
250
+ }
251
+ }
252
+ exports.AggregatedStats = AggregatedStats;
253
253
  //# sourceMappingURL=AggregatedStats.js.map
@@ -1,11 +1,11 @@
1
- "use strict";
2
- // Copyright Epic Games, Inc. All Rights Reserved.
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.CandidatePairStats = void 0;
5
- /**
6
- * ICE Candidate Pair Stats collected from the RTC Stats Report
7
- */
8
- class CandidatePairStats {
9
- }
10
- exports.CandidatePairStats = CandidatePairStats;
1
+ "use strict";
2
+ // Copyright Epic Games, Inc. All Rights Reserved.
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.CandidatePairStats = void 0;
5
+ /**
6
+ * ICE Candidate Pair Stats collected from the RTC Stats Report
7
+ */
8
+ class CandidatePairStats {
9
+ }
10
+ exports.CandidatePairStats = CandidatePairStats;
11
11
  //# sourceMappingURL=CandidatePairStats.js.map
@@ -1,11 +1,11 @@
1
- "use strict";
2
- // Copyright Epic Games, Inc. All Rights Reserved.
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.CandidateStat = void 0;
5
- /**
6
- * ICE Candidate Stat collected from the RTC Stats Report
7
- */
8
- class CandidateStat {
9
- }
10
- exports.CandidateStat = CandidateStat;
1
+ "use strict";
2
+ // Copyright Epic Games, Inc. All Rights Reserved.
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.CandidateStat = void 0;
5
+ /**
6
+ * ICE Candidate Stat collected from the RTC Stats Report
7
+ */
8
+ class CandidateStat {
9
+ }
10
+ exports.CandidateStat = CandidateStat;
11
11
  //# sourceMappingURL=CandidateStat.js.map
@@ -1,11 +1,11 @@
1
- "use strict";
2
- // Copyright Epic Games, Inc. All Rights Reserved.
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.CodecStats = void 0;
5
- /**
6
- * Codec Stats collected from the RTC Stats Report
7
- */
8
- class CodecStats {
9
- }
10
- exports.CodecStats = CodecStats;
1
+ "use strict";
2
+ // Copyright Epic Games, Inc. All Rights Reserved.
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.CodecStats = void 0;
5
+ /**
6
+ * Codec Stats collected from the RTC Stats Report
7
+ */
8
+ class CodecStats {
9
+ }
10
+ exports.CodecStats = CodecStats;
11
11
  //# sourceMappingURL=CodecStats.js.map
@@ -1,11 +1,11 @@
1
- "use strict";
2
- // Copyright Epic Games, Inc. All Rights Reserved.
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.DataChannelStats = void 0;
5
- /**
6
- * Data Channel Stats collected from the RTC Stats Report
7
- */
8
- class DataChannelStats {
9
- }
10
- exports.DataChannelStats = DataChannelStats;
1
+ "use strict";
2
+ // Copyright Epic Games, Inc. All Rights Reserved.
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.DataChannelStats = void 0;
5
+ /**
6
+ * Data Channel Stats collected from the RTC Stats Report
7
+ */
8
+ class DataChannelStats {
9
+ }
10
+ exports.DataChannelStats = DataChannelStats;
11
11
  //# sourceMappingURL=DataChannelStats.js.map
@@ -1,23 +1,23 @@
1
- "use strict";
2
- // Copyright Epic Games, Inc. All Rights Reserved.
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.InboundRTPStats = exports.InboundVideoStats = exports.InboundAudioStats = void 0;
5
- /**
6
- * Inbound Audio Stats collected from the RTC Stats Report
7
- */
8
- class InboundAudioStats {
9
- }
10
- exports.InboundAudioStats = InboundAudioStats;
11
- /**
12
- * Inbound Video Stats collected from the RTC Stats Report
13
- */
14
- class InboundVideoStats {
15
- }
16
- exports.InboundVideoStats = InboundVideoStats;
17
- /**
18
- * Inbound Stats collected from the RTC Stats Report
19
- */
20
- class InboundRTPStats {
21
- }
22
- exports.InboundRTPStats = InboundRTPStats;
1
+ "use strict";
2
+ // Copyright Epic Games, Inc. All Rights Reserved.
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.InboundRTPStats = exports.InboundVideoStats = exports.InboundAudioStats = void 0;
5
+ /**
6
+ * Inbound Audio Stats collected from the RTC Stats Report
7
+ */
8
+ class InboundAudioStats {
9
+ }
10
+ exports.InboundAudioStats = InboundAudioStats;
11
+ /**
12
+ * Inbound Video Stats collected from the RTC Stats Report
13
+ */
14
+ class InboundVideoStats {
15
+ }
16
+ exports.InboundVideoStats = InboundVideoStats;
17
+ /**
18
+ * Inbound Stats collected from the RTC Stats Report
19
+ */
20
+ class InboundRTPStats {
21
+ }
22
+ exports.InboundRTPStats = InboundRTPStats;
23
23
  //# sourceMappingURL=InboundRTPStats.js.map