@observertc/client-monitor-js 2.2.2 → 3.0.0

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 (204) hide show
  1. package/README.md +79 -190
  2. package/lib/ClientMetaData.d.ts +27 -0
  3. package/lib/ClientMetaData.d.ts.map +1 -0
  4. package/lib/ClientMetaData.js +119 -0
  5. package/lib/ClientMonitor.d.ts +101 -339
  6. package/lib/ClientMonitor.d.ts.map +1 -1
  7. package/lib/ClientMonitor.js +224 -0
  8. package/lib/Collectors.d.ts +46 -52
  9. package/lib/Collectors.d.ts.map +1 -1
  10. package/lib/Collectors.js +166 -222
  11. package/lib/Detectors.d.ts +37 -0
  12. package/lib/Detectors.d.ts.map +1 -0
  13. package/lib/Detectors.js +115 -0
  14. package/lib/Sampler.d.ts +7 -28
  15. package/lib/Sampler.d.ts.map +1 -1
  16. package/lib/Sampler.js +354 -266
  17. package/lib/collectors/Adapter.d.ts +14 -0
  18. package/lib/collectors/Adapter.d.ts.map +1 -0
  19. package/lib/collectors/Adapter.js +57 -0
  20. package/lib/collectors/MediasoupStatsCollector.d.ts +18 -40
  21. package/lib/collectors/MediasoupStatsCollector.d.ts.map +1 -1
  22. package/lib/collectors/MediasoupStatsCollector.js +273 -376
  23. package/lib/collectors/MediasoupSurrogates.d.ts +65 -31
  24. package/lib/collectors/MediasoupSurrogates.d.ts.map +1 -1
  25. package/lib/collectors/PeerConnectionStatsCollector.d.ts +18 -16
  26. package/lib/collectors/PeerConnectionStatsCollector.d.ts.map +1 -1
  27. package/lib/collectors/PeerConnectionStatsCollector.js +106 -36
  28. package/lib/collectors/StatsCollector.d.ts +1 -18
  29. package/lib/collectors/StatsCollector.d.ts.map +1 -1
  30. package/lib/collectors/StatsProvider.d.ts +7 -0
  31. package/lib/collectors/StatsProvider.d.ts.map +1 -0
  32. package/lib/collectors/StatsProvider.js +11 -0
  33. package/lib/collectors/browserAdapterMiddlewares.d.ts +5 -0
  34. package/lib/collectors/browserAdapterMiddlewares.d.ts.map +1 -0
  35. package/lib/collectors/browserAdapterMiddlewares.js +75 -0
  36. package/lib/collectors/utils.d.ts +16 -0
  37. package/lib/collectors/utils.d.ts.map +1 -0
  38. package/lib/collectors/utils.js +73 -0
  39. package/lib/detectors/AudioDesyncDetector.d.ts +11 -7
  40. package/lib/detectors/AudioDesyncDetector.d.ts.map +1 -1
  41. package/lib/detectors/AudioDesyncDetector.js +38 -26
  42. package/lib/detectors/CongestionDetector.d.ts +18 -13
  43. package/lib/detectors/CongestionDetector.d.ts.map +1 -1
  44. package/lib/detectors/CongestionDetector.js +59 -38
  45. package/lib/detectors/{CpuIssueDetector.d.ts → CpuPerformanceDetector.d.ts} +10 -9
  46. package/lib/detectors/CpuPerformanceDetector.d.ts.map +1 -0
  47. package/lib/detectors/CpuPerformanceDetector.js +58 -0
  48. package/lib/entries/InboundTrackStats.d.ts +25 -0
  49. package/lib/entries/InboundTrackStats.d.ts.map +1 -0
  50. package/lib/entries/InboundTrackStats.js +89 -0
  51. package/lib/entries/OutboundTrackStats.d.ts +18 -0
  52. package/lib/entries/OutboundTrackStats.d.ts.map +1 -0
  53. package/lib/entries/OutboundTrackStats.js +53 -0
  54. package/lib/entries/PeerConnectionEntryManifest.d.ts +113 -0
  55. package/lib/entries/PeerConnectionEntryManifest.d.ts.map +1 -0
  56. package/lib/entries/PeerConnectionEntryManifest.js +936 -0
  57. package/lib/entries/StatsEntryInterfaces.d.ts +77 -94
  58. package/lib/entries/StatsEntryInterfaces.d.ts.map +1 -1
  59. package/lib/entries/StatsStorage.d.ts +73 -152
  60. package/lib/entries/StatsStorage.d.ts.map +1 -1
  61. package/lib/entries/StatsStorage.js +360 -291
  62. package/lib/entries/UpdateFields.d.ts +0 -5
  63. package/lib/entries/UpdateFields.d.ts.map +1 -1
  64. package/lib/entries/UpdateFields.js +1 -47
  65. package/lib/index.d.ts +19 -15
  66. package/lib/index.d.ts.map +1 -1
  67. package/lib/index.js +22 -7
  68. package/lib/schema/Samples.d.ts +0 -206
  69. package/lib/schema/Samples.d.ts.map +1 -1
  70. package/lib/schema/W3cStatsIdentifiers.d.ts +156 -114
  71. package/lib/schema/W3cStatsIdentifiers.d.ts.map +1 -1
  72. package/lib/schema/W3cStatsIdentifiers.js +2 -32
  73. package/lib/utils/IndexedMap.d.ts +26 -0
  74. package/lib/utils/IndexedMap.d.ts.map +1 -0
  75. package/lib/utils/IndexedMap.js +219 -0
  76. package/lib/utils/Processor.d.ts +7 -0
  77. package/lib/utils/Processor.d.ts.map +1 -0
  78. package/lib/utils/Processor.js +38 -0
  79. package/lib/utils/Stats.d.ts +60 -0
  80. package/lib/utils/Stats.d.ts.map +1 -0
  81. package/lib/utils/Stats.js +205 -0
  82. package/lib/utils/Timer.d.ts +13 -25
  83. package/lib/utils/Timer.d.ts.map +1 -1
  84. package/lib/utils/Timer.js +82 -127
  85. package/lib/utils/TypedEmitter.d.ts +14 -0
  86. package/lib/utils/TypedEmitter.d.ts.map +1 -0
  87. package/lib/utils/TypedEmitter.js +37 -0
  88. package/lib/utils/callEvents.d.ts +23 -11
  89. package/lib/utils/callEvents.d.ts.map +1 -1
  90. package/lib/utils/callEvents.js +158 -13
  91. package/lib/utils/common.d.ts +9 -6
  92. package/lib/utils/common.d.ts.map +1 -1
  93. package/lib/utils/common.js +7 -76
  94. package/lib/utils/logger.d.ts +17 -9
  95. package/lib/utils/logger.d.ts.map +1 -1
  96. package/lib/utils/logger.js +81 -127
  97. package/package.json +7 -7
  98. package/src/ClientMetaData.ts +115 -0
  99. package/src/ClientMonitor.ts +216 -366
  100. package/src/Collectors.ts +195 -276
  101. package/src/Detectors.ts +134 -0
  102. package/src/Sampler.ts +350 -304
  103. package/src/collectors/Adapter.ts +75 -0
  104. package/src/collectors/MediasoupStatsCollector.ts +320 -440
  105. package/src/collectors/MediasoupSurrogates.ts +72 -37
  106. package/src/collectors/PeerConnectionStatsCollector.ts +131 -55
  107. package/src/collectors/StatsCollector.ts +2 -23
  108. package/src/collectors/StatsProvider.ts +15 -0
  109. package/src/collectors/browserAdapterMiddlewares.ts +74 -0
  110. package/src/collectors/utils.ts +118 -0
  111. package/src/detectors/AudioDesyncDetector.ts +47 -35
  112. package/src/detectors/CongestionDetector.ts +101 -82
  113. package/src/detectors/{CpuIssueDetector.ts → CpuPerformanceDetector.ts} +35 -25
  114. package/src/entries/InboundTrackStats.ts +99 -0
  115. package/src/entries/OutboundTrackStats.ts +58 -0
  116. package/src/entries/PeerConnectionEntryManifest.ts +1045 -0
  117. package/src/entries/StatsEntryInterfaces.ts +93 -107
  118. package/src/entries/StatsStorage.ts +381 -494
  119. package/src/entries/UpdateFields.ts +0 -58
  120. package/src/index.ts +45 -21
  121. package/src/schema/Samples.ts +0 -218
  122. package/src/schema/W3cStatsIdentifiers.ts +212 -134
  123. package/src/utils/IndexedMap.ts +237 -0
  124. package/src/utils/Processor.ts +37 -0
  125. package/src/utils/Stats.ts +252 -0
  126. package/src/utils/Timer.ts +91 -142
  127. package/src/utils/TypedEmitter.ts +50 -0
  128. package/src/utils/callEvents.ts +179 -12
  129. package/src/utils/common.ts +14 -74
  130. package/src/utils/logger.ts +101 -145
  131. package/lib/Accumulator.d.ts +0 -35
  132. package/lib/Accumulator.d.ts.map +0 -1
  133. package/lib/Accumulator.js +0 -68
  134. package/lib/ClientDevices.d.ts +0 -23
  135. package/lib/ClientDevices.d.ts.map +0 -1
  136. package/lib/ClientDevices.js +0 -124
  137. package/lib/ClientMonitorImpl.d.ts +0 -82
  138. package/lib/ClientMonitorImpl.d.ts.map +0 -1
  139. package/lib/ClientMonitorImpl.js +0 -484
  140. package/lib/Evaluators.d.ts +0 -14
  141. package/lib/Evaluators.d.ts.map +0 -1
  142. package/lib/Evaluators.js +0 -29
  143. package/lib/Metrics.d.ts +0 -39
  144. package/lib/Metrics.d.ts.map +0 -1
  145. package/lib/Metrics.js +0 -30
  146. package/lib/adapters/Adapter.d.ts +0 -17
  147. package/lib/adapters/Adapter.d.ts.map +0 -1
  148. package/lib/adapters/Adapter.js +0 -159
  149. package/lib/adapters/Chrome86Adapter.d.ts +0 -6
  150. package/lib/adapters/Chrome86Adapter.d.ts.map +0 -1
  151. package/lib/adapters/Chrome86Adapter.js +0 -71
  152. package/lib/adapters/DefaultAdapter.d.ts +0 -6
  153. package/lib/adapters/DefaultAdapter.d.ts.map +0 -1
  154. package/lib/adapters/DefaultAdapter.js +0 -22
  155. package/lib/adapters/Firefox94Adapter.d.ts +0 -6
  156. package/lib/adapters/Firefox94Adapter.d.ts.map +0 -1
  157. package/lib/adapters/Firefox94Adapter.js +0 -38
  158. package/lib/adapters/Safari14Adapter.d.ts +0 -6
  159. package/lib/adapters/Safari14Adapter.d.ts.map +0 -1
  160. package/lib/adapters/Safari14Adapter.js +0 -63
  161. package/lib/alterters/AudioDesyncAlerter.d.ts +0 -35
  162. package/lib/alterters/AudioDesyncAlerter.d.ts.map +0 -1
  163. package/lib/alterters/AudioDesyncAlerter.js +0 -66
  164. package/lib/detectors/CpuIssueDetector.d.ts.map +0 -1
  165. package/lib/detectors/CpuIssueDetector.js +0 -43
  166. package/lib/detectors/LowMoSDetector.d.ts +0 -29
  167. package/lib/detectors/LowMoSDetector.d.ts.map +0 -1
  168. package/lib/detectors/LowMoSDetector.js +0 -36
  169. package/lib/detectors/LowStabilityScoreDetector.d.ts +0 -21
  170. package/lib/detectors/LowStabilityScoreDetector.d.ts.map +0 -1
  171. package/lib/detectors/LowStabilityScoreDetector.js +0 -43
  172. package/lib/entries/PeerConnectionEntryImpl.d.ts +0 -85
  173. package/lib/entries/PeerConnectionEntryImpl.d.ts.map +0 -1
  174. package/lib/entries/PeerConnectionEntryImpl.js +0 -1055
  175. package/lib/utils/MediaDevices.d.ts +0 -14
  176. package/lib/utils/MediaDevices.d.ts.map +0 -1
  177. package/lib/utils/MediaDevices.js +0 -87
  178. package/lib/utils/StatsVisitor.d.ts +0 -31
  179. package/lib/utils/StatsVisitor.d.ts.map +0 -1
  180. package/lib/utils/StatsVisitor.js +0 -106
  181. package/lib/utils/makeStamp.d.ts +0 -2
  182. package/lib/utils/makeStamp.d.ts.map +0 -1
  183. package/lib/utils/makeStamp.js +0 -39
  184. package/lib/utils/reverseEnums.d.ts +0 -6
  185. package/lib/utils/reverseEnums.d.ts.map +0 -1
  186. package/lib/utils/reverseEnums.js +0 -12
  187. package/src/Accumulator.ts +0 -99
  188. package/src/ClientDevices.ts +0 -118
  189. package/src/ClientMonitorImpl.ts +0 -555
  190. package/src/Evaluators.ts +0 -40
  191. package/src/Metrics.ts +0 -66
  192. package/src/adapters/Adapter.ts +0 -158
  193. package/src/adapters/Chrome86Adapter.ts +0 -65
  194. package/src/adapters/DefaultAdapter.ts +0 -20
  195. package/src/adapters/Firefox94Adapter.ts +0 -39
  196. package/src/adapters/Safari14Adapter.ts +0 -58
  197. package/src/alterters/AudioDesyncAlerter.ts +0 -105
  198. package/src/detectors/LowMoSDetector.ts +0 -63
  199. package/src/detectors/LowStabilityScoreDetector.ts +0 -57
  200. package/src/entries/PeerConnectionEntryImpl.ts +0 -1151
  201. package/src/utils/MediaDevices.ts +0 -85
  202. package/src/utils/StatsVisitor.ts +0 -142
  203. package/src/utils/makeStamp.ts +0 -36
  204. package/src/utils/reverseEnums.ts +0 -18
package/README.md CHANGED
@@ -8,7 +8,9 @@ Table of Contents:
8
8
  * [Quick Start](#quick-start)
9
9
  * [Integrations](#integrations)
10
10
  - [Mediasoup](#mediasoup)
11
- * [Alerts and Detectors](#alerts)
11
+ * [Detectors and Alerts](#detectors-and-alerts)
12
+ - [Audio Desync Detector](#audio-desync-detector)
13
+ - [CPU Performance Detector](#cpu-performance-detector)
12
14
  * [Calculated updates](#calculated-updates)
13
15
  * [Configurations](#configurations)
14
16
  * [NPM package](#npm-package)
@@ -70,7 +72,7 @@ const config = {
70
72
  const monitor = createClientMonitor(config);
71
73
  const mediasoupStatsCollector = monitor.collectors.collectFromMediasoupDevice(mediasoupDevice);
72
74
 
73
- monitor.events.onStatsCollected(() => {
75
+ monitor.on('stats-collected', () => {
74
76
  // do your stuff
75
77
 
76
78
  // you can close detach mediasoup
@@ -106,12 +108,11 @@ const monitor = createClientMonitor({
106
108
 
107
109
  const storage = monitor.storage;
108
110
  monitor.on('stats-collected', () => {
109
- const updates = storage.updates;
110
- console.log('average RTT in seconds', updates.avgRttInS);
111
- console.log('Sending audio bitrate', updates.sendingAudioBitrate);
112
- console.log('Sending video bitrate', updates.sendingVideoBitrate);
113
- console.log('Receiving audio bitrate', updates.receivingAudioBitrate);
114
- console.log('Receiving video bitrate', updates.receivingVideoBitrate);
111
+ console.log('average RTT in seconds', storage.avgRttInS);
112
+ console.log('Sending audio bitrate', storage.sendingAudioBitrate);
113
+ console.log('Sending video bitrate', storage.sendingVideoBitrate);
114
+ console.log('Receiving audio bitrate', storage.receivingAudioBitrate);
115
+ console.log('Receiving video bitrate', storage.receivingVideoBitrate);
115
116
 
116
117
  ```
117
118
 
@@ -128,12 +129,11 @@ const monitor = createClientMonitor({
128
129
  const storage = monitor.storage;
129
130
  monitor.on('stats-collected', () => {
130
131
  for (const peerConnection of storage.peerConnections()) {
131
- const updates = peerConnection.updates;
132
- console.log('average RTT in seconds', updates.avgRttInS);
133
- console.log('Sending audio bitrate on PC', updates.sendingAudioBitrate);
134
- console.log('Sending video bitrate on PC', updates.sendingVideoBitrate);
135
- console.log('Receiving audio bitrate on PC', updates.receivingAudioBitrate);
136
- console.log('Receiving video bitrate on PC', updates.receivingVideoBitrate);
132
+ console.log('average RTT in seconds', peerConnection.avgRttInS);
133
+ console.log('Sending audio bitrate on PC', peerConnection.sendingAudioBitrate);
134
+ console.log('Sending video bitrate on PC', peerConnection.sendingVideoBitrate);
135
+ console.log('Receiving audio bitrate on PC', peerConnection.receivingAudioBitrate);
136
+ console.log('Receiving video bitrate on PC', peerConnection.receivingVideoBitrate);
137
137
  }
138
138
  });
139
139
 
@@ -153,15 +153,12 @@ const storage = monitor.storage;
153
153
  monitor.on('stats-collected', () => {
154
154
  for (const inboundRtp of storage.inboundRtps()) {
155
155
 
156
- console.log('mean opinion score for inbound-rtp', inboundRtp.meanOpinionScore);
157
-
158
- const updates = inboundRtp.updates;
159
- console.log('receiving bitrate', updates.receivingBitrate);
160
- console.log('lost packets since last stats-collected', updates.lostPackets);
161
- console.log('received packets since last stats-collected', updates.receivedPackets);
162
- console.log('decoded frames since last stats-collected', updates.decodedFrames);
156
+ console.log('mean opinion score for inbound-rtp', inboundRtp.score);
163
157
 
164
- console.log('full list of calculations changed since last stats-collected ', updates);
158
+ console.log('receiving bitrate', inboundRtp.receivingBitrate);
159
+ console.log('lost packets since last stats-collected', inboundRtp.lostPackets);
160
+ console.log('received packets since last stats-collected', inboundRtp.receivedPackets);
161
+ console.log('decoded frames since last stats-collected', inboundRtp.decodedFrames);
165
162
  }
166
163
  });
167
164
 
@@ -181,35 +178,28 @@ const storage = monitor.storage;
181
178
  monitor.on('stats-collected', () => {
182
179
  for (const outboundRtp of storage.outboundRtps()) {
183
180
 
184
- console.log('stability score outbound-rtp', outboundRtp.stabilityScore);
181
+ console.log('stability score outbound-rtp', outboundRtp.score);
185
182
 
186
- const updates = outboundRtp.updates;
187
- console.log('sending bitrate', updates.sendingBitrate);
188
- console.log('sent packets since last stats-collected', updates.sentPackets);
183
+ console.log('sending bitrate', outboundRtp.sendingBitrate);
184
+ console.log('sent packets since last stats-collected', outboundRtp.sentPackets);
189
185
 
190
186
  const remoteInboundRtp = outboundRtp.getRemoteInboundRtp();
191
- console.log('Received packets on remote inbound-rtp belongs to this outbound-rtp', remoteInboundRtp?.updates.receivedPackets);
187
+ console.log('Received packets on remote inbound-rtp belongs to this outbound-rtp', remoteInboundRtp?.receivedPackets);
192
188
  }
193
189
  });
194
190
 
195
191
  ```
196
192
 
193
+ ## Detectors and Alerts
197
194
 
198
-
199
- ## Alerts and Detectors
200
-
201
- Alerts and detectors provide events of tracking and responding to anomalies or performance issues based on the polled stats. Detectors are components that continuously monitor for specific conditions in the polled stats, and set an alert if certain thresholds are hit. You can subscribe to alerts of an instantiated client-monitor-js and configure detectors via initial configurations.
202
-
203
-
204
- To configure the Congestion Detector according to your specific requirements, please refer to the [Configuration](#configuration) section for further guidance.
205
-
195
+ Detectors and alerts provide events of tracking and responding to anomalies or performance issues based on the polled stats. Detectors are components that continuously monitor for specific conditions in the polled stats, and set an alert if certain thresholds are hit. You can subscribe to alerts of an instantiated client-monitor-js and configure detectors via initial configurations.
206
196
 
207
197
  List of built-in alerts:
208
- * `stability-score-alert`: triggered whenever an outbound network is considered to be instable based on the calculated stability score
209
- * `mean-opinion-score-alert`: triggered when a calculated MoS score for an inbound-rtp is lower than the configured threshold
210
198
  * `audio-desync-alert`: triggered when for an audio track several acceleration and deceleration is detected in a short amount of time indicating that the controlling system tries compensate discrepancies.
211
199
  * `cpu-performance-alert`: triggered whenever a browser detects quality limitation becasue of CPU, or the number of decoded frames per sec hit a certain threshold
212
200
 
201
+ ### Audio Desync Detector
202
+
213
203
  ```javascript
214
204
  import { createClientMonitor } from 'client-monitor-js';
215
205
 
@@ -218,24 +208,27 @@ const monitor = createClientMonitor({
218
208
  collectingPeriodInMs: 2000,
219
209
  });
220
210
 
221
- monitor.on('alerts-changed', (alerts) => {
222
-
223
- const stabilityAlert = alerts['stability-score-alert'];
224
- if (stabilityAlert === 'on') {
225
- console.log('Network condition for sending media is instable');
226
- } else if (stabilityAlert === 'off') {
227
- console.log('Network condition for sending media is considered to be stable again');
228
- }
229
-
230
- const meanOpionionScoreAlert = alerts['mean-opinion-score-alert'];
231
- if (meanOpionionScoreAlert === 'on') {
232
- console.log('Mean opinion score for received media is considered to be low');
233
- } else if (meanOpionionScoreAlert === 'off') {
234
- console.log('Mean opinion score for received media is normalized');
235
- }
211
+ monitor.detectors.addAudioDesyncDetector({
212
+ /**
213
+ * The fractional threshold used to determine if the audio desynchronization
214
+ * correction is considered significant or not.
215
+ * It represents the minimum required ratio of corrected samples to total samples.
216
+ * For example, a value of 0.1 means that if the corrected samples ratio
217
+ * exceeds 0.1, it will be considered a significant audio desynchronization issue.
218
+ */
219
+ fractionalCorrectionAlertOnThreshold: 0.1;
220
+ /**
221
+ * The fractional threshold used to determine if the audio desynchronization
222
+ * correction is considered negligible and the alert should be turned off.
223
+ * It represents the maximum allowed ratio of corrected samples to total samples.
224
+ * For example, a value of 0.05 means that if the corrected samples ratio
225
+ * falls below 0.05, the audio desynchronization alert will be turned off.
226
+ */
227
+ fractionalCorrectionAlertOffThreshold: 0.2;
228
+ });
236
229
 
237
- const audioDesyncAlert = alerts['audio-desync-alert'];
238
- if (audioDesyncAlert === 'on') {
230
+ monitor.on('audio-desync-alert', (alertState) => {
231
+ if (alertState === 'on') {
239
232
  console.log('Audio is desynced from video');
240
233
  } else if (meanOpionionScoreAlert === 'off') {
241
234
  console.log('Audio is synced back');
@@ -243,17 +236,37 @@ monitor.on('alerts-changed', (alerts) => {
243
236
  });
244
237
  ```
245
238
 
239
+ ### CPU Performance Detector
246
240
 
247
- ### Outbound Stability Detector
248
-
249
- Outbound Stability Detector is based on a score calculated for each outbound tracks
250
- giving a normalized value between `0.0..1.0` indicate how reliable the network
251
- for transmitting media. The score consideres RTT fluctuations, and packet losses in it's calculation
252
-
253
- ### Mean Opinion Score Detector
241
+ ```javascript
242
+ monitor.detectors.addCpuPerformanceDetector({
243
+ /**
244
+ * The fractional threshold used to determine if the incoming frames
245
+ * dropped fraction is considered significant or not.
246
+ * It represents the maximum allowed ratio of dropped frames to received frames.
247
+ * For example, a value of 0.1 means that if the dropped frames fraction
248
+ * exceeds 0.1, it will be considered a significant issue.
249
+ */
250
+ droppedIncomingFramesFractionAlertOn: 0.5;
251
+ /**
252
+ * The fractional threshold used to determine if the incoming frames
253
+ * dropped fraction is considered negligible and the alert should be turned off.
254
+ * It represents the maximum allowed ratio of dropped frames to received frames.
255
+ * For example, a value of 0.05 means that if the dropped frames fraction
256
+ * falls below 0.05, the CPU issue alert will be turned off.
257
+ */
258
+ droppedIncomingFramesFractionAlertOff: 0.8;
259
+ })
254
260
 
255
- For each inbound-rtp a MoS is calculated, which is a value between `0.0..5.0` indicate the quality of the rendered media.
256
261
 
262
+ monitor.on('cpu-performance-alert', alertState => {
263
+ if (alertState === 'on') {
264
+ console.log('CPU performance problem is detected');
265
+ } else if (meanOpionionScoreAlert === 'off') {
266
+ console.log('CPU performance problem is gone');
267
+ }
268
+ })
269
+ ```
257
270
 
258
271
  ## Configurations
259
272
 
@@ -274,136 +287,12 @@ const config = {
274
287
  samplingPeriodInMs: 10000,
275
288
 
276
289
  /**
277
- * By setting it, the monitor sends the samples periodically.
290
+ * This is the interval the monitor periodically checks
291
+ * if collecting or sampling action should be invoked or not.
278
292
  *
279
- * DEFAULT: undefined
280
- */
281
- sendingPeriodInMs: 10000,
282
-
283
- /**
284
- * By enabling this option, the monitor automatically generates events
285
- * when a peer connection added to the collector undergoes a change in connection state or when a track on it is added or removed.
286
- *
287
- * If this option is set to true, the samples created by the monitor will include the generated events. However, if
288
- * no sample is created, events will accumulate indefinitely within the monitor. It is recommended to set this option to true
289
- * if you want to create a sample with events.
290
- *
291
- * DEFAULT: false
293
+ * DEFAULT: if collecting or sampling period is set the default value is 1000, otherwise it's undefined
292
294
  */
293
- createCallEvents: false,
294
-
295
- /**
296
- * Collector Component related configurations
297
- *
298
- * DEFAULT: configured by the monitor
299
- */
300
- collectors: {
301
- /**
302
- * Sets the adapter adapt different browser type and version
303
- * provided stats.
304
- *
305
- * DEFAULT: configured by the monitor
306
- */
307
- adapter: {
308
- /**
309
- * the type of the browser, e.g.: chrome, firefox, safari
310
- *
311
- * DEFAULT: configured by the collector
312
- */
313
- browserType: "chrome",
314
- /**
315
- * the version of the browser, e.g.: 97.xx.xxxxx
316
- *
317
- * DEFAULT: configured by the collector
318
- */
319
- browserVersion: "97.1111.111",
320
- },
321
- },
322
-
323
- /**
324
- * Configuration for the CpuIssueDetector function.
325
- *
326
- * Default configuration below
327
- */
328
- cpuIssueDetector: {
329
- /**
330
- * Specifies whether the CPU issue detector is enabled or not.
331
- */
332
- enabled: true;
333
- /**
334
- * The fractional threshold used to determine if the incoming frames
335
- * dropped fraction is considered significant or not.
336
- * It represents the maximum allowed ratio of dropped frames to received frames.
337
- * For example, a value of 0.1 means that if the dropped frames fraction
338
- * exceeds 0.1, it will be considered a significant issue.
339
- */
340
- droppedIncomingFramesFractionAlertOn: 0.5;
341
- /**
342
- * The fractional threshold used to determine if the incoming frames
343
- * dropped fraction is considered negligible and the alert should be turned off.
344
- * It represents the maximum allowed ratio of dropped frames to received frames.
345
- * For example, a value of 0.05 means that if the dropped frames fraction
346
- * falls below 0.05, the CPU issue alert will be turned off.
347
- */
348
- droppedIncomingFramesFractionAlertOff: 0.8;
349
- },
350
- /**
351
- * Configuration for the AudioDesyncDetector function.
352
- *
353
- * Default configuration below
354
- */
355
- audioDesyncDetector: {
356
- /**
357
- * Specifies whether the audio desynchronization detector is enabled or not.
358
- */
359
- enabled: true;
360
- /**
361
- * The fractional threshold used to determine if the audio desynchronization
362
- * correction is considered significant or not.
363
- * It represents the minimum required ratio of corrected samples to total samples.
364
- * For example, a value of 0.1 means that if the corrected samples ratio
365
- * exceeds 0.1, it will be considered a significant audio desynchronization issue.
366
- */
367
- fractionalCorrectionAlertOnThreshold: 0.1;
368
- /**
369
- * The fractional threshold used to determine if the audio desynchronization
370
- * correction is considered negligible and the alert should be turned off.
371
- * It represents the maximum allowed ratio of corrected samples to total samples.
372
- * For example, a value of 0.05 means that if the corrected samples ratio
373
- * falls below 0.05, the audio desynchronization alert will be turned off.
374
- */
375
- fractionalCorrectionAlertOffThreshold: 0.2;
376
- },
377
- lowStabilityScoreDetector: {
378
- /**
379
- * Boolean indicating whether the detector is enabled or not
380
- */
381
- enabled: true;
382
- /**
383
- * The threshold at which an alert is turned on
384
- */
385
- alertOnThreshold: 0.8;
386
- /**
387
- * The threshold at which an alert is turned off
388
- */
389
- alertOffThreshold: 0.9;
390
- },
391
- lowMosDetector: {
392
- /**
393
- * Specifies whether the Low Mean Opinion Score detector is enabled or not.
394
- */
395
- enabled: true;
396
- /**
397
- * The threshold value for triggering a Low Mean Opinion Score alert.
398
- * If the mean opinion score (MOS) falls below this value, an alert will be triggered.
399
- */
400
- alertOnThreshold: 3.0;
401
- /**
402
- * The threshold value for turning off the Low Mean Opinion Score alert.
403
- * If the mean opinion score (MOS) rises above this value, the alert will be turned off.
404
- */
405
- alertOffThreshold: 4.0;
406
- }
295
+ tickingTimeInMs: 10000,
407
296
  };
408
297
  ```
409
298
 
@@ -0,0 +1,27 @@
1
+ import { OperationSystem, Browser, Platform, Engine, MediaDevice } from './schema/Samples';
2
+ export type StoredMediaDevice = MediaDevice & {
3
+ sampled: boolean;
4
+ };
5
+ export declare class ClientMetaData {
6
+ readonly operationSystem: OperationSystem;
7
+ readonly browser: Browser;
8
+ readonly platform: Platform;
9
+ readonly engine: Engine;
10
+ private readonly _mediaDevices;
11
+ constructor();
12
+ set mediaDevices(values: MediaDevice[]);
13
+ get mediaDevices(): MediaDevice[];
14
+ /**
15
+ * Iterable iterator for the audio input devices obtained by the observer.
16
+ */
17
+ audioInputs(): IterableIterator<StoredMediaDevice>;
18
+ /**
19
+ * Iterable iterator for the audio output devices obtained by the observer.
20
+ */
21
+ audioOutputs(): IterableIterator<StoredMediaDevice>;
22
+ /**
23
+ * Iterable iterator for the video input devices obtained by the observer.
24
+ */
25
+ videoInputs(): IterableIterator<StoredMediaDevice>;
26
+ }
27
+ //# sourceMappingURL=ClientMetaData.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ClientMetaData.d.ts","sourceRoot":"","sources":["../src/ClientMetaData.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,eAAe,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AA+B3F,MAAM,MAAM,iBAAiB,GAAG,WAAW,GAAG;IAC1C,OAAO,EAAE,OAAO,CAAC;CACpB,CAAA;AAED,qBAAa,cAAc;IACvB,SAAgB,eAAe,EAAE,eAAe,CAAC;IACjD,SAAgB,OAAO,EAAE,OAAO,CAAC;IACjC,SAAgB,QAAQ,EAAE,QAAQ,CAAC;IACnC,SAAgB,MAAM,EAAE,MAAM,CAAC;IAC/B,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAyD;;IA8BvF,IAAW,YAAY,CAAC,MAAM,EAAE,WAAW,EAAE,EAe5C;IAED,IAAW,YAAY,IAAI,WAAW,EAAE,CAEvC;IAED;;OAEG;IACI,WAAW,IAAI,gBAAgB,CAAC,iBAAiB,CAAC;IAIzD;;OAEG;IACI,YAAY,IAAI,gBAAgB,CAAC,iBAAiB,CAAC;IAI1D;;OAEG;IACI,WAAW,IAAI,gBAAgB,CAAC,iBAAiB,CAAC;CAG5D"}
@@ -0,0 +1,119 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.ClientMetaData = void 0;
27
+ const Bowser = __importStar(require("bowser"));
28
+ const logger_1 = require("./utils/logger");
29
+ const IndexedMap_1 = require("./utils/IndexedMap");
30
+ // import * as proto from "./ProtobufSamples"
31
+ const logger = (0, logger_1.createLogger)("ClientDevices");
32
+ const UNKNOWN_OS = {
33
+ name: "Unkown",
34
+ version: undefined,
35
+ versionName: undefined,
36
+ };
37
+ const UNKNOWN_BROWSER = {
38
+ name: "Unknown",
39
+ version: undefined,
40
+ };
41
+ const UNKNOWN_PLATFORM = {
42
+ type: "Unknown",
43
+ vendor: undefined,
44
+ model: undefined,
45
+ };
46
+ const UNKNOWN_ENGINE = {
47
+ name: "Unknown",
48
+ version: undefined,
49
+ };
50
+ const MEDIA_DEVICE_KIND = 'mediaDeviceKind';
51
+ class ClientMetaData {
52
+ constructor() {
53
+ try {
54
+ /* eslint-disable @typescript-eslint/no-explicit-any */
55
+ let outerNavigator = undefined;
56
+ if (navigator !== undefined)
57
+ outerNavigator = navigator;
58
+ else if (window !== undefined && window.navigator !== undefined)
59
+ outerNavigator = window.navigator;
60
+ else
61
+ throw new Error(`navigator is not available`);
62
+ const parsedResult = Bowser.parse(outerNavigator.userAgent);
63
+ this.browser = parsedResult.browser;
64
+ this.engine = parsedResult.engine;
65
+ this.operationSystem = parsedResult.os;
66
+ this.platform = parsedResult.platform;
67
+ }
68
+ catch (err) {
69
+ logger.warn(`Cannot collect media devices and navigator data, because an error occurred`, err);
70
+ this.operationSystem = UNKNOWN_OS;
71
+ this.browser = UNKNOWN_BROWSER;
72
+ this.platform = UNKNOWN_PLATFORM;
73
+ this.engine = UNKNOWN_ENGINE;
74
+ }
75
+ this._mediaDevices = new IndexedMap_1.IndexedMap()
76
+ .addIndex(MEDIA_DEVICE_KIND, (device) => device.kind);
77
+ }
78
+ set mediaDevices(values) {
79
+ const visited = new Set();
80
+ for (const mediaDevice of values) {
81
+ if (!mediaDevice.id)
82
+ continue;
83
+ visited.add(mediaDevice.id);
84
+ if (this._mediaDevices.has(mediaDevice.id))
85
+ continue;
86
+ this._mediaDevices.set(mediaDevice.id, {
87
+ ...mediaDevice,
88
+ sampled: false,
89
+ });
90
+ }
91
+ for (const [id] of this._mediaDevices.entries()) {
92
+ if (visited.has(id))
93
+ continue;
94
+ this._mediaDevices.delete(id);
95
+ }
96
+ }
97
+ get mediaDevices() {
98
+ return Array.from(this._mediaDevices.values());
99
+ }
100
+ /**
101
+ * Iterable iterator for the audio input devices obtained by the observer.
102
+ */
103
+ audioInputs() {
104
+ return this._mediaDevices.values(MEDIA_DEVICE_KIND, "audioinput");
105
+ }
106
+ /**
107
+ * Iterable iterator for the audio output devices obtained by the observer.
108
+ */
109
+ audioOutputs() {
110
+ return this._mediaDevices.values(MEDIA_DEVICE_KIND, "audiooutput");
111
+ }
112
+ /**
113
+ * Iterable iterator for the video input devices obtained by the observer.
114
+ */
115
+ videoInputs() {
116
+ return this._mediaDevices.values(MEDIA_DEVICE_KIND, "videoinput");
117
+ }
118
+ }
119
+ exports.ClientMetaData = ClientMetaData;