@observertc/observer-js 0.42.9 → 1.0.1-57a1811.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 (247) hide show
  1. package/.prettierrc +6 -6
  2. package/README.md +0 -104
  3. package/lib/ObservedCall.d.ts +38 -41
  4. package/lib/ObservedCall.d.ts.map +1 -1
  5. package/lib/ObservedCall.js +97 -109
  6. package/lib/ObservedCertificate.d.ts +19 -0
  7. package/lib/ObservedCertificate.d.ts.map +1 -0
  8. package/lib/ObservedCertificate.js +38 -0
  9. package/lib/ObservedClient.d.ts +49 -127
  10. package/lib/ObservedClient.d.ts.map +1 -1
  11. package/lib/ObservedClient.js +201 -750
  12. package/lib/ObservedCodec.d.ts +22 -0
  13. package/lib/ObservedCodec.d.ts.map +1 -0
  14. package/lib/ObservedCodec.js +45 -0
  15. package/lib/ObservedDataChannel.d.ts +23 -69
  16. package/lib/ObservedDataChannel.d.ts.map +1 -1
  17. package/lib/ObservedDataChannel.js +67 -109
  18. package/lib/ObservedIceCandidate.d.ts +29 -0
  19. package/lib/ObservedIceCandidate.d.ts.map +1 -0
  20. package/lib/ObservedIceCandidate.js +59 -0
  21. package/lib/ObservedIceCandidatePair.d.ts +44 -0
  22. package/lib/ObservedIceCandidatePair.d.ts.map +1 -0
  23. package/lib/ObservedIceCandidatePair.js +111 -0
  24. package/lib/ObservedIceTransport.d.ts +32 -0
  25. package/lib/ObservedIceTransport.d.ts.map +1 -0
  26. package/lib/ObservedIceTransport.js +65 -0
  27. package/lib/ObservedInboundRtp.d.ts +92 -0
  28. package/lib/ObservedInboundRtp.d.ts.map +1 -0
  29. package/lib/ObservedInboundRtp.js +193 -0
  30. package/lib/ObservedInboundTrack.d.ts +29 -0
  31. package/lib/ObservedInboundTrack.d.ts.map +1 -0
  32. package/lib/ObservedInboundTrack.js +57 -0
  33. package/lib/ObservedMediaPlayout.d.ts +22 -0
  34. package/lib/ObservedMediaPlayout.d.ts.map +1 -0
  35. package/lib/ObservedMediaPlayout.js +42 -0
  36. package/lib/ObservedMediaSource.d.ts +28 -0
  37. package/lib/ObservedMediaSource.d.ts.map +1 -0
  38. package/lib/ObservedMediaSource.js +55 -0
  39. package/lib/ObservedOutboundRtp.d.ts +62 -0
  40. package/lib/ObservedOutboundRtp.d.ts.map +1 -0
  41. package/lib/ObservedOutboundRtp.js +144 -0
  42. package/lib/ObservedOutboundTrack.d.ts +29 -0
  43. package/lib/ObservedOutboundTrack.d.ts.map +1 -0
  44. package/lib/ObservedOutboundTrack.js +57 -0
  45. package/lib/ObservedPeerConnection.d.ts +128 -78
  46. package/lib/ObservedPeerConnection.d.ts.map +1 -1
  47. package/lib/ObservedPeerConnection.js +624 -357
  48. package/lib/ObservedPeerConnectionTransport.d.ts +17 -0
  49. package/lib/ObservedPeerConnectionTransport.d.ts.map +1 -0
  50. package/lib/ObservedPeerConnectionTransport.js +34 -0
  51. package/lib/ObservedRemoteInboundRtp.d.ts +30 -0
  52. package/lib/ObservedRemoteInboundRtp.d.ts.map +1 -0
  53. package/lib/ObservedRemoteInboundRtp.js +60 -0
  54. package/lib/ObservedRemoteOutboundRtp.d.ts +30 -0
  55. package/lib/ObservedRemoteOutboundRtp.d.ts.map +1 -0
  56. package/lib/ObservedRemoteOutboundRtp.js +60 -0
  57. package/lib/ObservedTURN.d.ts +31 -0
  58. package/lib/ObservedTURN.d.ts.map +1 -0
  59. package/lib/ObservedTURN.js +58 -0
  60. package/lib/ObservedTurnServer.d.ts +25 -0
  61. package/lib/ObservedTurnServer.d.ts.map +1 -0
  62. package/lib/ObservedTurnServer.js +59 -0
  63. package/lib/Observer.d.ts +31 -51
  64. package/lib/Observer.d.ts.map +1 -1
  65. package/lib/Observer.js +75 -229
  66. package/lib/common/Middleware.d.ts +10 -1
  67. package/lib/common/Middleware.d.ts.map +1 -1
  68. package/lib/common/Middleware.js +55 -36
  69. package/lib/common/logger.d.ts +8 -4
  70. package/lib/common/logger.d.ts.map +1 -1
  71. package/lib/common/logger.js +44 -68
  72. package/lib/common/types.d.ts +0 -21
  73. package/lib/common/types.d.ts.map +1 -1
  74. package/lib/common/types.js +1 -0
  75. package/lib/common/utils.d.ts +1 -0
  76. package/lib/common/utils.d.ts.map +1 -1
  77. package/lib/common/utils.js +13 -1
  78. package/lib/detectors/Detector.d.ts +5 -0
  79. package/lib/detectors/Detector.d.ts.map +1 -0
  80. package/lib/detectors/Detector.js +3 -0
  81. package/lib/detectors/Detectors.d.ts +11 -0
  82. package/lib/detectors/Detectors.d.ts.map +1 -0
  83. package/lib/detectors/Detectors.js +34 -0
  84. package/lib/index.d.ts +24 -25
  85. package/lib/index.d.ts.map +1 -1
  86. package/lib/index.js +41 -41
  87. package/lib/monitors/TurnUsageMonitor.d.ts +0 -52
  88. package/lib/monitors/TurnUsageMonitor.d.ts.map +1 -1
  89. package/lib/monitors/TurnUsageMonitor.js +145 -120
  90. package/lib/schema/ClientEventTypes.d.ts +33 -0
  91. package/lib/schema/ClientEventTypes.d.ts.map +1 -0
  92. package/lib/schema/ClientEventTypes.js +38 -0
  93. package/lib/schema/ClientMetaTypes.d.ts +34 -0
  94. package/lib/schema/ClientMetaTypes.d.ts.map +1 -0
  95. package/lib/schema/ClientMetaTypes.js +16 -0
  96. package/lib/schema/ClientSample.d.ts +1333 -0
  97. package/lib/schema/ClientSample.d.ts.map +1 -0
  98. package/lib/schema/ClientSample.js +4 -0
  99. package/lib/scores/CalculatedScore.d.ts +6 -0
  100. package/lib/scores/CalculatedScore.d.ts.map +1 -0
  101. package/lib/scores/DefaultCallScoreCalculator.d.ts +7 -0
  102. package/lib/scores/DefaultCallScoreCalculator.d.ts.map +1 -0
  103. package/lib/scores/DefaultCallScoreCalculator.js +21 -0
  104. package/lib/scores/ScoreCalculator.d.ts +4 -0
  105. package/lib/scores/ScoreCalculator.d.ts.map +1 -0
  106. package/lib/scores/ScoreCalculator.js +2 -0
  107. package/lib/utils/CallUpdater.d.ts +5 -0
  108. package/lib/utils/CallUpdater.d.ts.map +1 -0
  109. package/lib/utils/CallUpdater.js +2 -0
  110. package/lib/utils/OnAllClientCallUpdater.d.ts +16 -0
  111. package/lib/utils/OnAllClientCallUpdater.d.ts.map +1 -0
  112. package/lib/utils/OnAllClientCallUpdater.js +58 -0
  113. package/lib/utils/RemoteTrackResolver.d.ts +7 -0
  114. package/lib/utils/RemoteTrackResolver.d.ts.map +1 -0
  115. package/lib/utils/RemoteTrackResolver.js +2 -0
  116. package/lib/utils/onAnyClientCallUpdater.d.ts +14 -0
  117. package/lib/utils/onAnyClientCallUpdater.d.ts.map +1 -0
  118. package/lib/utils/onAnyClientCallUpdater.js +51 -0
  119. package/package.json +4 -4
  120. package/src/ObservedCall.ts +116 -166
  121. package/src/ObservedCertificate.ts +43 -0
  122. package/src/ObservedClient.ts +213 -1060
  123. package/src/ObservedCodec.ts +49 -0
  124. package/src/ObservedDataChannel.ts +68 -181
  125. package/src/ObservedIceCandidate.ts +64 -0
  126. package/src/ObservedIceCandidatePair.ts +118 -0
  127. package/src/ObservedIceTransport.ts +70 -0
  128. package/src/ObservedInboundRtp.ts +205 -0
  129. package/src/ObservedInboundTrack.ts +70 -0
  130. package/src/ObservedMediaPlayout.ts +49 -0
  131. package/src/ObservedMediaSource.ts +60 -0
  132. package/src/ObservedOutboundRtp.ts +156 -0
  133. package/src/ObservedOutboundTrack.ts +69 -0
  134. package/src/ObservedPeerConnection.ts +827 -405
  135. package/src/ObservedPeerConnectionTransport.ts +38 -0
  136. package/src/ObservedRemoteInboundRtp.ts +64 -0
  137. package/src/ObservedRemoteOutboundRtp.ts +65 -0
  138. package/src/ObservedTURN.ts +86 -0
  139. package/src/ObservedTurnServer.ts +72 -0
  140. package/src/Observer.ts +91 -302
  141. package/src/common/Middleware.ts +70 -42
  142. package/src/common/logger.ts +60 -69
  143. package/src/common/types.ts +0 -42
  144. package/src/common/utils.ts +12 -0
  145. package/src/detectors/Detector.ts +6 -0
  146. package/src/detectors/Detectors.ts +38 -0
  147. package/src/index.ts +24 -90
  148. package/src/monitors/TurnUsageMonitor.ts +164 -164
  149. package/src/schema/ClientEventTypes.ts +36 -0
  150. package/src/schema/ClientMetaTypes.ts +41 -0
  151. package/src/schema/ClientSample.ts +1682 -0
  152. package/src/scores/CalculatedScore.ts +6 -0
  153. package/src/scores/DefaultCallScoreCalculator.ts +23 -0
  154. package/src/scores/ScoreCalculator.ts +3 -0
  155. package/src/utils/CallUpdater.ts +5 -0
  156. package/src/utils/OnAllClientCallUpdater.ts +68 -0
  157. package/src/utils/RemoteTrackResolver.ts +12 -0
  158. package/src/utils/onAnyClientCallUpdater.ts +59 -0
  159. package/tsconfig.json +3 -3
  160. package/lib/ObservedICE.d.ts +0 -64
  161. package/lib/ObservedICE.d.ts.map +0 -1
  162. package/lib/ObservedICE.js +0 -141
  163. package/lib/ObservedInboundAudioTrack.d.ts +0 -96
  164. package/lib/ObservedInboundAudioTrack.d.ts.map +0 -1
  165. package/lib/ObservedInboundAudioTrack.js +0 -217
  166. package/lib/ObservedInboundVideoTrack.d.ts +0 -101
  167. package/lib/ObservedInboundVideoTrack.d.ts.map +0 -1
  168. package/lib/ObservedInboundVideoTrack.js +0 -232
  169. package/lib/ObservedOutboundAudioTrack.d.ts +0 -87
  170. package/lib/ObservedOutboundAudioTrack.d.ts.map +0 -1
  171. package/lib/ObservedOutboundAudioTrack.js +0 -186
  172. package/lib/ObservedOutboundVideoTrack.d.ts +0 -91
  173. package/lib/ObservedOutboundVideoTrack.d.ts.map +0 -1
  174. package/lib/ObservedOutboundVideoTrack.js +0 -193
  175. package/lib/ObservedSfu.d.ts +0 -59
  176. package/lib/ObservedSfu.d.ts.map +0 -1
  177. package/lib/ObservedSfu.js +0 -157
  178. package/lib/ObservedSfuInboundRtpPad.d.ts +0 -42
  179. package/lib/ObservedSfuInboundRtpPad.d.ts.map +0 -1
  180. package/lib/ObservedSfuInboundRtpPad.js +0 -71
  181. package/lib/ObservedSfuOutboundRtpPad.d.ts +0 -42
  182. package/lib/ObservedSfuOutboundRtpPad.d.ts.map +0 -1
  183. package/lib/ObservedSfuOutboundRtpPad.js +0 -72
  184. package/lib/ObservedSfuSctpChannel.d.ts +0 -42
  185. package/lib/ObservedSfuSctpChannel.d.ts.map +0 -1
  186. package/lib/ObservedSfuSctpChannel.js +0 -57
  187. package/lib/ObservedSfuTransport.d.ts +0 -58
  188. package/lib/ObservedSfuTransport.d.ts.map +0 -1
  189. package/lib/ObservedSfuTransport.js +0 -120
  190. package/lib/RemoteTrackAssigner.d.ts +0 -14
  191. package/lib/RemoteTrackAssigner.d.ts.map +0 -1
  192. package/lib/RemoteTrackAssigner.js +0 -52
  193. package/lib/ReportsCollector.d.ts +0 -109
  194. package/lib/ReportsCollector.d.ts.map +0 -1
  195. package/lib/ReportsCollector.js +0 -207
  196. package/lib/common/CalculatedScore.d.ts +0 -80
  197. package/lib/common/CalculatedScore.d.ts.map +0 -1
  198. package/lib/common/CalculatedScore.js +0 -162
  199. package/lib/common/CallEventType.d.ts +0 -63
  200. package/lib/common/CallEventType.d.ts.map +0 -1
  201. package/lib/common/CallEventType.js +0 -39
  202. package/lib/common/CallMetaReports.d.ts +0 -42
  203. package/lib/common/CallMetaReports.d.ts.map +0 -1
  204. package/lib/common/CallMetaReports.js +0 -36
  205. package/lib/common/QualityScoreUtils.d.ts +0 -1
  206. package/lib/common/QualityScoreUtils.d.ts.map +0 -1
  207. package/lib/common/QualityScoreUtils.js +0 -1
  208. package/lib/common/TypedEventEmitter.d.ts +0 -22
  209. package/lib/common/TypedEventEmitter.d.ts.map +0 -1
  210. package/lib/common/TypedEventEmitter.js +0 -11
  211. package/lib/common/callEventReports.d.ts +0 -10
  212. package/lib/common/callEventReports.d.ts.map +0 -1
  213. package/lib/common/callEventReports.js +0 -112
  214. package/lib/monitors/CallSummary.d.ts +0 -37
  215. package/lib/monitors/CallSummary.d.ts.map +0 -1
  216. package/lib/monitors/CallSummaryMonitor.d.ts +0 -32
  217. package/lib/monitors/CallSummaryMonitor.d.ts.map +0 -1
  218. package/lib/monitors/CallSummaryMonitor.js +0 -152
  219. package/lib/monitors/ClientIssueMonitor.d.ts +0 -32
  220. package/lib/monitors/ClientIssueMonitor.d.ts.map +0 -1
  221. package/lib/monitors/ClientIssueMonitor.js +0 -49
  222. package/lib/monitors/SfuServerMonitor.d.ts +0 -79
  223. package/lib/monitors/SfuServerMonitor.d.ts.map +0 -1
  224. package/lib/monitors/SfuServerMonitor.js +0 -198
  225. package/src/ObservedICE.ts +0 -237
  226. package/src/ObservedInboundAudioTrack.ts +0 -344
  227. package/src/ObservedInboundVideoTrack.ts +0 -361
  228. package/src/ObservedOutboundAudioTrack.ts +0 -307
  229. package/src/ObservedOutboundVideoTrack.ts +0 -319
  230. package/src/ObservedSfu.ts +0 -231
  231. package/src/ObservedSfuInboundRtpPad.ts +0 -106
  232. package/src/ObservedSfuOutboundRtpPad.ts +0 -107
  233. package/src/ObservedSfuSctpChannel.ts +0 -103
  234. package/src/ObservedSfuTransport.ts +0 -185
  235. package/src/RemoteTrackAssigner.ts +0 -68
  236. package/src/ReportsCollector.ts +0 -336
  237. package/src/common/CalculatedScore.ts +0 -188
  238. package/src/common/CallEventType.ts +0 -69
  239. package/src/common/CallMetaReports.ts +0 -82
  240. package/src/common/QualityScoreUtils.ts +0 -0
  241. package/src/common/TypedEventEmitter.ts +0 -32
  242. package/src/common/callEventReports.ts +0 -178
  243. package/src/monitors/CallSummary.ts +0 -38
  244. package/src/monitors/CallSummaryMonitor.ts +0 -192
  245. package/src/monitors/ClientIssueMonitor.ts +0 -88
  246. package/src/monitors/SfuServerMonitor.ts +0 -285
  247. /package/lib/{monitors/CallSummary.js → scores/CalculatedScore.js} +0 -0
@@ -1,336 +0,0 @@
1
- import {
2
- CallEventReport,
3
- CallMetaReport,
4
- ClientDataChannelReport,
5
- ClientExtensionReport,
6
- IceCandidatePairReport,
7
- InboundAudioTrackReport,
8
- InboundVideoTrackReport,
9
- ObserverEventReport,
10
- OutboundAudioTrackReport,
11
- OutboundVideoTrackReport,
12
- PeerConnectionTransportReport,
13
- SfuEventReport,
14
- SfuExtensionReport,
15
- SfuInboundRtpPadReport,
16
- SfuMetaReport,
17
- SfuOutboundRtpPadReport,
18
- SfuSctpStreamReport,
19
- SFUTransportReport,
20
- } from '@observertc/report-schemas-js';
21
- import { EventEmitter } from 'events';
22
- import { ObserverSinkContext } from './common/types';
23
-
24
- export type SinkEventsMap = {
25
- 'call-event': {
26
- reports: CallEventReport[];
27
- };
28
- 'call-meta': {
29
- reports: CallMetaReport[];
30
- };
31
- 'client-data-channel': {
32
- reports: ClientDataChannelReport[];
33
- };
34
- 'client-extension': {
35
- reports: ClientExtensionReport[];
36
- };
37
- 'ice-candidate-pair': {
38
- reports: IceCandidatePairReport[];
39
- };
40
- 'peer-connection-transport': {
41
- reports: PeerConnectionTransportReport[];
42
- };
43
- 'inbound-audio-track': {
44
- reports: InboundAudioTrackReport[];
45
- };
46
- 'inbound-video-track': {
47
- reports: InboundVideoTrackReport[];
48
- };
49
- 'observer-event': {
50
- reports: ObserverEventReport[]
51
- };
52
- 'outbound-audio-track': {
53
- reports: OutboundAudioTrackReport[];
54
- };
55
- 'outbound-video-track': {
56
- reports: OutboundVideoTrackReport[];
57
- };
58
- 'sfu-event': {
59
- reports: SfuEventReport[];
60
- };
61
- 'sfu-extension': {
62
- reports: SfuExtensionReport[];
63
- };
64
- 'sfu-inbound-rtp-pad': {
65
- reports: SfuInboundRtpPadReport[];
66
- };
67
- 'sfu-outbound-rtp-pad': {
68
- reports: SfuOutboundRtpPadReport[];
69
- };
70
- 'sfu-sctp-stream': {
71
- reports: SfuSctpStreamReport[];
72
- };
73
- 'sfu-transport': {
74
- reports: SFUTransportReport[];
75
- };
76
- 'sfu-meta': {
77
- reports: SfuMetaReport[];
78
- };
79
- 'reports': ObserverSinkContext;
80
- 'newreport': number;
81
- };
82
-
83
- export type ObserverSinkProcess = (observerSinkContext: ObserverSinkContext) => Promise<void>;
84
-
85
- export class ReportsCollector {
86
- private _collectedReports = 0;
87
- private _emitter = new EventEmitter();
88
- private _callEventReports: CallEventReport[] = [];
89
- private _callMetaReports: CallMetaReport[] = [];
90
- private _clientDataChannelReports: ClientDataChannelReport[] = [];
91
- private _clientExtensionReports: ClientExtensionReport[] = [];
92
- private _iceCandidatePairReports: IceCandidatePairReport[] = [];
93
- private _inboundAudioTrackReports: InboundAudioTrackReport[] = [];
94
- private _inboundVideoTrackReports: InboundVideoTrackReport[] = [];
95
- private _peerConnectionTransportReports: PeerConnectionTransportReport[] = [];
96
- private _observerEventReports: ObserverEventReport[] = [];
97
- private _outboundAudioTrackReports: OutboundAudioTrackReport[] = [];
98
- private _outboundVideoTrackReports: OutboundVideoTrackReport[] = [];
99
- private _sfuEventReports: SfuEventReport[] = [];
100
- private _sfuExtensionReports: SfuExtensionReport[] = [];
101
- private _sfuInboundRtpPadReports: SfuInboundRtpPadReport[] = [];
102
- private _sfuOutboundRtpPadReports: SfuOutboundRtpPadReport[] = [];
103
- private _sfuSctpStreamReports: SfuSctpStreamReport[] = [];
104
- private _sfuTransportReports: SFUTransportReport[] = [];
105
- private _sfuMetaReports: SfuMetaReport[] = [];
106
-
107
- public constructor() {
108
- // empty
109
- }
110
-
111
- public on<K extends keyof SinkEventsMap>(event: K, listener: (reports: SinkEventsMap[K]) => void): this {
112
- this._emitter.addListener(event, listener);
113
-
114
- return this;
115
- }
116
-
117
- public off<K extends keyof SinkEventsMap>(event: K, listener: (reports: SinkEventsMap[K]) => void): this {
118
- this._emitter.removeListener(event, listener);
119
-
120
- return this;
121
- }
122
-
123
- public once<K extends keyof SinkEventsMap>(event: K, listener: (reports: SinkEventsMap[K]) => void): this {
124
- this._emitter.once(event, listener);
125
-
126
- return this;
127
- }
128
-
129
- public addCallEventReport(report: CallEventReport) {
130
- this._callEventReports.push(report);
131
- this._emit('newreport', ++this._collectedReports);
132
- }
133
-
134
- public addCallMetaReport(report: CallMetaReport) {
135
- this._callMetaReports.push(report);
136
- this._emit('newreport', ++this._collectedReports);
137
- }
138
-
139
- public addClientDataChannelReport(report: ClientDataChannelReport) {
140
- this._clientDataChannelReports.push(report);
141
- this._emit('newreport', ++this._collectedReports);
142
- }
143
-
144
- public addClientExtensionReport(report: ClientExtensionReport) {
145
- this._clientExtensionReports.push(report);
146
- this._emit('newreport', ++this._collectedReports);
147
- }
148
-
149
- public addIceCandidatePairReport(report: IceCandidatePairReport) {
150
- this._iceCandidatePairReports.push(report);
151
- this._emit('newreport', ++this._collectedReports);
152
- }
153
-
154
- public addInboundAudioTrackReport(report: InboundAudioTrackReport) {
155
- this._inboundAudioTrackReports.push(report);
156
- this._emit('newreport', ++this._collectedReports);
157
- }
158
-
159
- public addInboundVideoTrackReport(report: InboundVideoTrackReport) {
160
- this._inboundVideoTrackReports.push(report);
161
- this._emit('newreport', ++this._collectedReports);
162
- }
163
-
164
- public addPeerConnectionTransportReports(report: PeerConnectionTransportReport) {
165
- this._peerConnectionTransportReports.push(report);
166
- this._emit('newreport', ++this._collectedReports);
167
- }
168
-
169
- public addObserverEventReport(report: ObserverEventReport) {
170
- this._observerEventReports.push(report);
171
- this._emit('newreport', ++this._collectedReports);
172
- }
173
-
174
- public addOutboundAudioTrackReport(report: OutboundAudioTrackReport) {
175
- this._outboundAudioTrackReports.push(report);
176
- this._emit('newreport', ++this._collectedReports);
177
- }
178
-
179
- public addOutboundVideoTrackReport(report: OutboundVideoTrackReport) {
180
- this._outboundVideoTrackReports.push(report);
181
- this._emit('newreport', ++this._collectedReports);
182
- }
183
-
184
- public addSfuEventReport(report: SfuEventReport) {
185
- this._sfuEventReports.push(report);
186
- this._emit('newreport', ++this._collectedReports);
187
- }
188
-
189
- public addSfuExtensionReport(report: SfuExtensionReport) {
190
- this._sfuExtensionReports.push(report);
191
- this._emit('newreport', ++this._collectedReports);
192
- }
193
-
194
- public addSfuInboundRtpPadReport(report: SfuInboundRtpPadReport) {
195
- this._sfuInboundRtpPadReports.push(report);
196
- this._emit('newreport', ++this._collectedReports);
197
- }
198
-
199
- public addSfuOutboundRtpPadReport(report: SfuOutboundRtpPadReport) {
200
- this._sfuOutboundRtpPadReports.push(report);
201
- this._emit('newreport', ++this._collectedReports);
202
- }
203
-
204
- public addSfuSctpStreamReport(report: SfuSctpStreamReport) {
205
- this._sfuSctpStreamReports.push(report);
206
- this._emit('newreport', ++this._collectedReports);
207
- }
208
-
209
- public addSfuTransportReport(report: SFUTransportReport) {
210
- this._sfuTransportReports.push(report);
211
- this._emit('newreport', ++this._collectedReports);
212
- }
213
-
214
- public addSfuMetaReport(report: SfuMetaReport) {
215
- this._sfuMetaReports.push(report);
216
- this._emit('newreport', ++this._collectedReports);
217
- }
218
-
219
- public emit(): number {
220
- let result = 0;
221
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
222
- const checkAndEmit = (eventName: keyof SinkEventsMap, reports: any[]) => {
223
- if (0 < reports.length) {
224
- this._emit(eventName, { reports });
225
- result += reports.length;
226
- }
227
- };
228
-
229
- const context = this._createObserverSinkContext();
230
-
231
- checkAndEmit('call-event', this._callEventReports);
232
- this._callEventReports = [];
233
-
234
- checkAndEmit('call-meta', this._callMetaReports);
235
- this._callMetaReports = [];
236
-
237
- checkAndEmit('client-data-channel', this._clientDataChannelReports);
238
- this._clientDataChannelReports = [];
239
-
240
- checkAndEmit('client-extension', this._clientExtensionReports);
241
- this._clientExtensionReports = [];
242
-
243
- checkAndEmit('ice-candidate-pair', this._iceCandidatePairReports);
244
- this._iceCandidatePairReports = [];
245
-
246
- checkAndEmit('inbound-audio-track', this._inboundAudioTrackReports);
247
- this._inboundAudioTrackReports = [];
248
-
249
- checkAndEmit('inbound-video-track', this._inboundVideoTrackReports);
250
- this._inboundVideoTrackReports = [];
251
-
252
- checkAndEmit('peer-connection-transport', this._peerConnectionTransportReports);
253
- this._peerConnectionTransportReports = [];
254
-
255
- checkAndEmit('observer-event', this._observerEventReports);
256
- this._observerEventReports = [];
257
-
258
- checkAndEmit('outbound-audio-track', this._outboundAudioTrackReports);
259
- this._outboundAudioTrackReports = [];
260
-
261
- checkAndEmit('outbound-video-track', this._outboundVideoTrackReports);
262
- this._outboundVideoTrackReports = [];
263
-
264
- checkAndEmit('sfu-event', this._sfuEventReports);
265
- this._sfuEventReports = [];
266
-
267
- checkAndEmit('sfu-extension', this._sfuExtensionReports);
268
- this._sfuExtensionReports = [];
269
-
270
- checkAndEmit('sfu-inbound-rtp-pad', this._sfuInboundRtpPadReports);
271
- this._sfuInboundRtpPadReports = [];
272
-
273
- checkAndEmit('sfu-outbound-rtp-pad', this._sfuOutboundRtpPadReports);
274
- this._sfuOutboundRtpPadReports = [];
275
-
276
- checkAndEmit('sfu-sctp-stream', this._sfuSctpStreamReports);
277
- this._sfuSctpStreamReports = [];
278
-
279
- checkAndEmit('sfu-transport', this._sfuTransportReports);
280
- this._sfuTransportReports = [];
281
-
282
- checkAndEmit('sfu-meta', this._sfuMetaReports);
283
- this._sfuMetaReports = [];
284
-
285
- this._emit('reports', context);
286
- this._collectedReports = 0;
287
-
288
- return result;
289
- }
290
-
291
- private _emit<K extends keyof SinkEventsMap>(event: K, reports: SinkEventsMap[K]): boolean {
292
- return this._emitter.emit(event, reports);
293
- }
294
-
295
- private _createObserverSinkContext(): ObserverSinkContext {
296
- const callEventReports = [ ...this._callEventReports ];
297
- const callMetaReports = [ ...this._callMetaReports ];
298
- const clientDataChannelReports = [ ...this._clientDataChannelReports ];
299
- const clientExtensionReports = [ ...this._clientExtensionReports ];
300
- const iceCandidatePairReports = [ ...this._iceCandidatePairReports ];
301
- const inboundAudioTrackReports = [ ...this._inboundAudioTrackReports ];
302
- const inboundVideoTrackReports = [ ...this._inboundVideoTrackReports ];
303
- const peerConnectionTransportReports = [ ...this._peerConnectionTransportReports ];
304
- const observerEventReports = [ ...this._observerEventReports ];
305
- const outboundAudioTrackReports = [ ...this._outboundAudioTrackReports ];
306
- const outboundVideoTrackReports = [ ...this._outboundVideoTrackReports ];
307
- const sfuEventReports = [ ...this._sfuEventReports ];
308
- const sfuExtensionReports = [ ...this._sfuExtensionReports ];
309
- const sfuInboundRtpPadReports = [ ...this._sfuInboundRtpPadReports ];
310
- const sfuOutboundRtpPadReports = [ ...this._sfuOutboundRtpPadReports ];
311
- const sfuSctpStreamReports = [ ...this._sfuSctpStreamReports ];
312
- const sfuTransportReports = [ ...this._sfuTransportReports ];
313
- const sfuMetaReports = [ ...this._sfuMetaReports ];
314
-
315
- return {
316
- callEventReports,
317
- callMetaReports,
318
- clientDataChannelReports,
319
- clientExtensionReports,
320
- iceCandidatePairReports,
321
- inboundAudioTrackReports,
322
- inboundVideoTrackReports,
323
- peerConnectionTransportReports,
324
- observerEventReports,
325
- outboundAudioTrackReports,
326
- outboundVideoTrackReports,
327
- sfuEventReports,
328
- sfuExtensionReports,
329
- sfuInboundRtpPadReports,
330
- sfuOutboundRtpPadReports,
331
- sfuSctpStreamReports,
332
- sfuTransportReports,
333
- sfuMetaReports,
334
- };
335
- }
336
- }
@@ -1,188 +0,0 @@
1
- import { ClientIssue } from '../monitors/CallSummary';
2
- import { ObservedInboundVideoTrack } from '../ObservedInboundVideoTrack';
3
- import { ObservedInboundAudioTrack } from '../ObservedInboundAudioTrack';
4
- import { ObservedOutboundVideoTrack } from '../ObservedOutboundVideoTrack';
5
- import { ObservedOutboundAudioTrack } from '../ObservedOutboundAudioTrack';
6
-
7
- export type CalculationRemark = {
8
- severity: 'none' | 'minor' | 'major' | 'critical',
9
- text: string,
10
- }
11
-
12
- export type CalculatedScore = {
13
- score: number,
14
- timestamp: number,
15
- remarks: CalculationRemark[],
16
- debugText?: string,
17
- }
18
-
19
- // every track calculates its own score and stores
20
- // the latest CalculatedScore in a score property also emits as an event 'score'
21
- // every peer connection collects the scores and calculates its own score based on RTT, and stores it in the score property similar to track
22
- // every client collects the scores and calculates its own score based on the peer connection scores, and stores it in the score property similar to track
23
- // every call collects the scores and calculates its own score based on the client scores, and stores it in the score property similar to track, but
24
- // but calls only recalculate it after a configured amount of time passed from the last recalculation, and it does not trigger automatically
25
-
26
- /*
27
- Recommended bpp Ranges for Good Quality
28
-
29
- | Content Type | H.264 (AVC) bpp Range | H.265 (HEVC) bpp Range | VP8 bpp Range | VP9 bpp Range |
30
- |--------------------|-----------------------|-----------------------|---------------|---------------|
31
- | Low Motion | 0.1 - 0.2 | 0.05 - 0.15 | 0.1 - 0.2 | 0.05 - 0.15 |
32
- | Standard Motion | 0.15 - 0.25 | 0.1 - 0.2 | 0.15 - 0.25 | 0.1 - 0.2 |
33
- | High Motion | 0.25 - 0.4 | 0.15 - 0.3 | 0.25 - 0.4 | 0.15 - 0.3 |
34
-
35
- */
36
- export const BPP_RANGES = {
37
- 'lowmotion': {
38
- 'h264': { low: 0.1, high: 0.2 },
39
- 'h265': { low: 0.05, high: 0.15 },
40
- 'vp8': { low: 0.1, high: 0.2 },
41
- 'vp9': { low: 0.05, high: 0.15 },
42
- },
43
- 'standard': {
44
- 'h264': { low: 0.15, high: 0.25 },
45
- 'h265': { low: 0.1, high: 0.2 },
46
- 'vp8': { low: 0.15, high: 0.25 },
47
- 'vp9': { low: 0.1, high: 0.2 },
48
- },
49
- 'highmotion': {
50
- 'h264': { low: 0.25, high: 0.4 },
51
- 'h265': { low: 0.15, high: 0.3 },
52
- 'vp8': { low: 0.25, high: 0.4 },
53
- 'vp9': { low: 0.15, high: 0.3 },
54
- },
55
- };
56
-
57
- export function calculateBaseVideoScore(track: ObservedInboundVideoTrack | ObservedOutboundVideoTrack, newIssues: ClientIssue[]): CalculatedScore | undefined {
58
- if (!track.highestLayer) {
59
- return;
60
- }
61
- const {
62
- frameHeight,
63
- frameWidth,
64
- framesPerSecond,
65
- bitrate,
66
- } = track.highestLayer;
67
- const score: CalculatedScore = {
68
- remarks: [],
69
- score: 0.0,
70
- timestamp: track.statsTimestamp,
71
- };
72
-
73
- if (!frameHeight || !frameWidth || !bitrate || !framesPerSecond) {
74
- score.score = 0.0;
75
- score.remarks.push({
76
- severity: 'major',
77
- text: 'Missing data for score calculation',
78
- });
79
-
80
- return score;
81
- }
82
-
83
- const bpp = bitrate / (frameHeight * frameWidth * framesPerSecond);
84
- // let's assume vp8 for now
85
- const bppRange = BPP_RANGES[track.contentType][track.codec ?? 'vp8'];
86
-
87
- if (bpp / 2 < bppRange.low) {
88
- score.score = 0.5;
89
- score.remarks.push({
90
- severity: 'major',
91
- text: `Bitrate per pixel is too low for ${track.contentType} content`,
92
- });
93
- } else if (bppRange.low < bpp) {
94
- score.score = 0.8;
95
- score.remarks.push({
96
- severity: 'minor',
97
- text: `Bitrate per pixel is good for ${track.contentType} content`,
98
- });
99
- } else {
100
- score.score = Math.min(1.0, ((bpp - bppRange.low) / (bppRange.high - bppRange.low)));
101
- score.remarks.push({
102
- severity: 'none',
103
- text: `Bitrate per pixel is good for ${track.contentType} content`,
104
- });
105
- }
106
-
107
- for (const issue of newIssues) {
108
- if (issue.severity === 'critical') {
109
- score.score = 0.0;
110
- } else if (issue.severity === 'major') {
111
- score.score *= 0.5;
112
- } else if (issue.severity === 'minor') {
113
- score.score *= 0.8;
114
- }
115
- score.remarks.push({
116
- severity: issue.severity,
117
- text: issue.description ?? 'Issue occurred',
118
- });
119
- }
120
-
121
- return score;
122
- }
123
-
124
- export function calculateBaseAudioScore(track: ObservedInboundAudioTrack | ObservedOutboundAudioTrack, newIssues: ClientIssue[]): CalculatedScore | undefined {
125
- const score: CalculatedScore = {
126
- remarks: [],
127
- score: 0.0,
128
- timestamp: track.statsTimestamp,
129
- };
130
-
131
- if (track.bitrate < 8000) {
132
- score.score = 0.2;
133
- score.remarks.push({
134
- severity: 'none',
135
- text: 'Bitrate is too low for good quality audio',
136
- });
137
- } else if (track.bitrate < 16000) {
138
- score.score = 0.5;
139
- score.remarks.push({
140
- severity: 'none',
141
- text: 'Bitrate is low for audio',
142
- });
143
- } else {
144
- score.score = 1.0;
145
- score.remarks.push({
146
- severity: 'none',
147
- text: 'Bitrate is good for audio',
148
- });
149
- }
150
-
151
- for (const issues of newIssues) {
152
- if (issues.severity === 'critical') {
153
- score.score = 0.0;
154
- } else if (issues.severity === 'major') {
155
- score.score *= 0.5;
156
- } else if (issues.severity === 'minor') {
157
- score.score *= 0.8;
158
- }
159
- score.remarks.push({
160
- severity: issues.severity,
161
- text: issues.description ?? 'Issue occurred',
162
- });
163
- }
164
-
165
- return score;
166
- }
167
-
168
- export function calculateLatencyMOS(
169
- { avgJitter, rttInMs, packetsLoss }:
170
- { avgJitter: number, rttInMs: number, packetsLoss: number },
171
- ): number {
172
- const effectiveLatency = rttInMs + (avgJitter * 2) + 10;
173
- let rFactor = effectiveLatency < 160
174
- ? 93.2 - (effectiveLatency / 40)
175
- : 93.2 - (effectiveLatency / 120) - 10;
176
-
177
- rFactor -= (packetsLoss * 2.5);
178
-
179
- return 1 + ((0.035) * rFactor) + ((0.000007) * rFactor * (rFactor - 60) * (100 - rFactor));
180
- }
181
-
182
- export function getRttScore(x: number): number {
183
- // logarithmic version: 1.0 at 150 and 0.1 at 300
184
- return (-1.2984 * Math.log(x)) + 7.5059;
185
-
186
- // exponential version: 1.0 at 150 and 0.1 at 300
187
- // return Math.exp(-0.01536 * x);
188
- }
@@ -1,69 +0,0 @@
1
- // eslint-disable-next-line no-shadow
2
- export enum CallEventType {
3
- CALL_STARTED = 'CALL_STARTED',
4
- CALL_ENDED = 'CALL_ENDED',
5
- CLIENT_JOINED = 'CLIENT_JOINED',
6
- CLIENT_LEFT = 'CLIENT_LEFT',
7
- PEER_CONNECTION_OPENED = 'PEER_CONNECTION_OPENED',
8
- PEER_CONNECTION_CLOSED = 'PEER_CONNECTION_CLOSED',
9
- MEDIA_TRACK_ADDED = 'MEDIA_TRACK_ADDED',
10
- MEDIA_TRACK_REMOVED = 'MEDIA_TRACK_REMOVED',
11
- MEDIA_TRACK_RESUMED = 'MEDIA_TRACK_RESUMED',
12
- MEDIA_TRACK_MUTED = 'MEDIA_TRACK_MUTED',
13
- MEDIA_TRACK_UNMUTED = 'MEDIA_TRACK_UNMUTED',
14
- ICE_GATHERING_STATE_CHANGED = 'ICE_GATHERING_STATE_CHANGED',
15
- PEER_CONNECTION_STATE_CHANGED = 'PEER_CONNECTION_STATE_CHANGED',
16
- ICE_CONNECTION_STATE_CHANGED = 'ICE_CONNECTION_STATE_CHANGED',
17
- DATA_CHANNEL_OPEN = 'DATA_CHANNEL_OPEN',
18
- DATA_CHANNEL_CLOSED = 'DATA_CHANNEL_CLOSED',
19
- DATA_CHANNEL_ERROR = 'DATA_CHANNEL_ERROR',
20
- NEGOTIATION_NEEDED = 'NEGOTIATION_NEEDED',
21
- SIGNALING_STATE_CHANGE = 'SIGNALING_STATE_CHANGE',
22
- CLIENT_ISSUE = 'CLIENT_ISSUE',
23
-
24
- PRODUCER_ADDED = 'PRODUCER_ADDED',
25
- PRODUCER_PAUSED = 'PRODUCER_PAUSED',
26
- PRODUCER_RESUMED = 'PRODUCER_RESUMED',
27
- PRODUCER_REMOVED = 'PRODUCER_REMOVED',
28
- CONSUMER_ADDED = 'CONSUMER_ADDED',
29
- CONSUMER_PAUSED = 'CONSUMER_PAUSED',
30
- CONSUMER_RESUMED = 'CONSUMER_RESUMED',
31
- CONSUMER_REMOVED = 'CONSUMER_REMOVED',
32
- DATA_PRODUCER_OPENED = 'DATA_PRODUCER_OPENED',
33
- DATA_PRODUCER_CLOSED = 'DATA_PRODUCER_CLOSED',
34
- DATA_CONSUMER_OPENED = 'DATA_CONSUMER_OPENED',
35
- DATA_CONSUMER_CLOSED = 'DATA_CONSUMER_CLOSED',
36
- }
37
-
38
- export type CallEventReportType = {
39
- name: CallEventType.MEDIA_TRACK_ADDED,
40
- attachment: MediaTrackAddedAttachment,
41
- } | {
42
- name: CallEventType.PEER_CONNECTION_STATE_CHANGED,
43
- attachment: PeerConnectionStateChangedAttachment,
44
- } | {
45
- name: CallEventType.ICE_CONNECTION_STATE_CHANGED,
46
- attachment: IceConnectionStateChangedAttachment,
47
- } | {
48
- name: CallEventType.ICE_GATHERING_STATE_CHANGED,
49
- attachment: IceGatheringStateChangedAttachment,
50
- }
51
-
52
- export type MediaTrackAddedAttachment = {
53
- kind?: 'audio' | 'video',
54
- direction?: 'inbound' | 'outbound',
55
- sfuStreamId?: string,
56
- sfuSinkId?: string,
57
- }
58
-
59
- export type PeerConnectionStateChangedAttachment = {
60
- iceConnectionState?: 'closed' | 'connected' | 'connecting' | 'disconnected' | 'failed' | 'new',
61
- }
62
-
63
- export type IceConnectionStateChangedAttachment = {
64
- iceConnectionState?: 'new' | 'connected' | 'disconnected' | 'failed' | 'closed' | 'checking' | 'completed',
65
- }
66
-
67
- export type IceGatheringStateChangedAttachment = {
68
- iceGatheringState?: 'new' | 'gathering' | 'complete',
69
- }
@@ -1,82 +0,0 @@
1
- import { CallMetaReport } from '@observertc/report-schemas-js';
2
- import {
3
- Browser,
4
- Certificate,
5
- Engine,
6
- IceLocalCandidate,
7
- IceRemoteCandidate,
8
- MediaCodecStats,
9
- MediaDevice,
10
- MediaSourceStat,
11
- OperationSystem,
12
- Platform,
13
- } from '@observertc/sample-schemas-js';
14
-
15
- // eslint-disable-next-line no-shadow
16
- export enum CallMetaType {
17
- CERTIFICATE = 'CERTIFICATE',
18
- CODEC = 'CODEC',
19
- ICE_LOCAL_CANDIDATE = 'ICE_LOCAL_CANDIDATE',
20
- ICE_REMOTE_CANDIDATE = 'ICE_REMOTE_CANDIDATE',
21
- ICE_SERVER = 'ICE_SERVER',
22
- MEDIA_CONSTRAINT = 'MEDIA_CONSTRAINT',
23
- MEDIA_DEVICE = 'MEDIA_DEVICE',
24
- MEDIA_SOURCE = 'MEDIA_SOURCE',
25
- USER_MEDIA_ERROR = 'USER_MEDIA_ERROR',
26
- LOCAL_SDP = 'LOCAL_SDP',
27
-
28
- OPERATION_SYSTEM = 'OPERATION_SYSTEM',
29
- ENGINE = 'ENGINE',
30
- PLATFORM = 'PLATFORM',
31
- BROWSER = 'BROWSER',
32
- }
33
-
34
- export type CallMetaReportPayloads = {
35
- [CallMetaType.CERTIFICATE]: Certificate;
36
- [CallMetaType.CODEC]: MediaCodecStats;
37
- [CallMetaType.ICE_LOCAL_CANDIDATE]: IceLocalCandidate;
38
- [CallMetaType.ICE_REMOTE_CANDIDATE]: IceRemoteCandidate;
39
- [CallMetaType.ICE_SERVER]: string;
40
- [CallMetaType.MEDIA_CONSTRAINT]: string;
41
- [CallMetaType.MEDIA_DEVICE]: MediaDevice;
42
- [CallMetaType.MEDIA_SOURCE]: MediaSourceStat;
43
- [CallMetaType.USER_MEDIA_ERROR]: string;
44
- [CallMetaType.OPERATION_SYSTEM]: OperationSystem;
45
- [CallMetaType.PLATFORM]: Platform;
46
- [CallMetaType.ENGINE]: Engine;
47
- [CallMetaType.LOCAL_SDP]: string;
48
- [CallMetaType.BROWSER]: Browser;
49
- }
50
-
51
- export type CallMetaReportType ={
52
- [k in keyof CallMetaReportPayloads]: {
53
- type: k;
54
- payload: CallMetaReportPayloads[k]
55
- };
56
- }[keyof CallMetaReportPayloads];
57
-
58
- export function createCallMetaReport(
59
- serviceId: string,
60
- mediaUnitId: string,
61
- roomId: string,
62
- callId: string,
63
- clientId: string,
64
- reportType: CallMetaReportType,
65
- userId?: string,
66
- peerConnectionId?: string,
67
- timestamp?: number
68
- ) {
69
- const report: CallMetaReport = {
70
- type: reportType.type,
71
- serviceId,
72
- mediaUnitId,
73
- roomId,
74
- callId,
75
- clientId,
76
- userId,
77
- payload: JSON.stringify(reportType.payload),
78
- timestamp: timestamp ?? Date.now(),
79
- };
80
-
81
- return report;
82
- }
File without changes