@observertc/observer-js 0.9.27-beta → 0.30.0-e12fcb4.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 (298) hide show
  1. package/lib/ObservedCall.d.ts +54 -0
  2. package/lib/ObservedCall.d.ts.map +1 -0
  3. package/lib/ObservedCall.js +166 -0
  4. package/lib/ObservedClient.d.ts +73 -0
  5. package/lib/ObservedClient.d.ts.map +1 -0
  6. package/lib/ObservedClient.js +487 -0
  7. package/lib/ObservedInboundTrack.d.ts +65 -0
  8. package/lib/ObservedInboundTrack.d.ts.map +1 -0
  9. package/lib/ObservedInboundTrack.js +192 -0
  10. package/lib/ObservedOutboundTrack.d.ts +55 -0
  11. package/lib/ObservedOutboundTrack.d.ts.map +1 -0
  12. package/lib/ObservedOutboundTrack.js +166 -0
  13. package/lib/ObservedPeerConnection.d.ts +57 -0
  14. package/lib/ObservedPeerConnection.d.ts.map +1 -0
  15. package/lib/ObservedPeerConnection.js +217 -0
  16. package/lib/Observer.d.ts +26 -1465
  17. package/lib/Observer.d.ts.map +1 -1
  18. package/lib/Observer.js +53 -605
  19. package/lib/{sinks/ObserverSink.d.ts → ReportsCollector.d.ts} +7 -23
  20. package/lib/ReportsCollector.d.ts.map +1 -0
  21. package/lib/{sinks/ObserverSink.js → ReportsCollector.js} +27 -85
  22. package/lib/common/ReportsCollector.d.ts +21 -24
  23. package/lib/common/ReportsCollector.d.ts.map +1 -1
  24. package/lib/common/ReportsCollector.js +24 -0
  25. package/lib/common/SingleExecutor.d.ts +3 -0
  26. package/lib/common/SingleExecutor.d.ts.map +1 -0
  27. package/lib/common/SingleExecutor.js +31 -0
  28. package/lib/common/TypedEventEmitter.d.ts +22 -0
  29. package/lib/common/TypedEventEmitter.d.ts.map +1 -0
  30. package/lib/common/TypedEventEmitter.js +11 -0
  31. package/lib/common/callEventReports.d.ts.map +1 -0
  32. package/lib/common/logger.d.ts +3 -9
  33. package/lib/common/logger.d.ts.map +1 -1
  34. package/lib/common/logger.js +58 -141
  35. package/lib/common/types.d.ts +2 -14
  36. package/lib/common/types.d.ts.map +1 -1
  37. package/lib/common/utils.d.ts +1 -0
  38. package/lib/common/utils.d.ts.map +1 -1
  39. package/lib/common/utils.js +6 -1
  40. package/lib/index.d.ts +8 -19
  41. package/lib/index.d.ts.map +1 -1
  42. package/lib/index.js +7 -2
  43. package/package.json +1 -1
  44. package/src/ObservedCall.ts +201 -0
  45. package/src/ObservedClient.ts +681 -0
  46. package/src/ObservedInboundTrack.ts +238 -0
  47. package/src/ObservedOutboundTrack.ts +205 -0
  48. package/src/ObservedPeerConnection.ts +249 -0
  49. package/src/Observer.ts +86 -442
  50. package/src/{sinks/ObserverSink.ts → ReportsCollector.ts} +29 -94
  51. package/src/common/ReportsCollector.ts +48 -23
  52. package/src/common/SingleExecutor.ts +36 -0
  53. package/src/common/TypedEventEmitter.ts +32 -0
  54. package/src/common/logger.ts +58 -161
  55. package/src/common/types.ts +4 -24
  56. package/src/common/utils.ts +6 -0
  57. package/src/index.ts +12 -23
  58. package/lib/Evaluator.d.ts +0 -43
  59. package/lib/Evaluator.d.ts.map +0 -1
  60. package/lib/Evaluator.js +0 -171
  61. package/lib/common/Semaphore.d.ts +0 -31
  62. package/lib/common/Semaphore.d.ts.map +0 -1
  63. package/lib/common/Semaphore.js +0 -16
  64. package/lib/entries/CallEntry.d.ts +0 -619
  65. package/lib/entries/CallEntry.d.ts.map +0 -1
  66. package/lib/entries/CallEntry.js +0 -75
  67. package/lib/entries/ClientEntry.d.ts +0 -478
  68. package/lib/entries/ClientEntry.d.ts.map +0 -1
  69. package/lib/entries/ClientEntry.js +0 -114
  70. package/lib/entries/InboundTrackEntry.d.ts +0 -682
  71. package/lib/entries/InboundTrackEntry.d.ts.map +0 -1
  72. package/lib/entries/InboundTrackEntry.js +0 -76
  73. package/lib/entries/OutboundTrackEntry.d.ts +0 -682
  74. package/lib/entries/OutboundTrackEntry.d.ts.map +0 -1
  75. package/lib/entries/OutboundTrackEntry.js +0 -73
  76. package/lib/entries/PeerConnectionEntry.d.ts +0 -505
  77. package/lib/entries/PeerConnectionEntry.d.ts.map +0 -1
  78. package/lib/entries/PeerConnectionEntry.js +0 -144
  79. package/lib/entries/SfuEntry.d.ts +0 -150
  80. package/lib/entries/SfuEntry.d.ts.map +0 -1
  81. package/lib/entries/SfuEntry.js +0 -77
  82. package/lib/entries/SfuInboundRtpPadEntry.d.ts +0 -14
  83. package/lib/entries/SfuInboundRtpPadEntry.d.ts.map +0 -1
  84. package/lib/entries/SfuInboundRtpPadEntry.js +0 -49
  85. package/lib/entries/SfuOutboundRtpPadEntry.d.ts +0 -14
  86. package/lib/entries/SfuOutboundRtpPadEntry.d.ts.map +0 -1
  87. package/lib/entries/SfuOutboundRtpPadEntry.js +0 -47
  88. package/lib/entries/SfuSctpChannelEntry.d.ts +0 -12
  89. package/lib/entries/SfuSctpChannelEntry.d.ts.map +0 -1
  90. package/lib/entries/SfuSctpChannelEntry.js +0 -43
  91. package/lib/entries/SfuTransportEntry.d.ts +0 -82
  92. package/lib/entries/SfuTransportEntry.d.ts.map +0 -1
  93. package/lib/entries/SfuTransportEntry.js +0 -122
  94. package/lib/evaluators/SetClientsCoordinateEvaluator.d.ts +0 -9
  95. package/lib/evaluators/SetClientsCoordinateEvaluator.d.ts.map +0 -1
  96. package/lib/evaluators/SetClientsCoordinateEvaluator.js +0 -95
  97. package/lib/middlewares/CallOperationsContext.d.ts +0 -18
  98. package/lib/middlewares/CallOperationsContext.d.ts.map +0 -1
  99. package/lib/middlewares/CallOperationsContext.js +0 -27
  100. package/lib/middlewares/CallProcessor.d.ts +0 -6
  101. package/lib/middlewares/CallProcessor.d.ts.map +0 -1
  102. package/lib/middlewares/CallProcessor.js +0 -36
  103. package/lib/middlewares/CommitTransactionMiddleware.d.ts +0 -6
  104. package/lib/middlewares/CommitTransactionMiddleware.d.ts.map +0 -1
  105. package/lib/middlewares/CommitTransactionMiddleware.js +0 -179
  106. package/lib/middlewares/DeleteOutdatedCallEntries.d.ts +0 -6
  107. package/lib/middlewares/DeleteOutdatedCallEntries.d.ts.map +0 -1
  108. package/lib/middlewares/DeleteOutdatedCallEntries.js +0 -121
  109. package/lib/middlewares/DeleteOutdatedSfuEntries.d.ts +0 -6
  110. package/lib/middlewares/DeleteOutdatedSfuEntries.d.ts.map +0 -1
  111. package/lib/middlewares/DeleteOutdatedSfuEntries.js +0 -127
  112. package/lib/middlewares/Middleware.d.ts +0 -3
  113. package/lib/middlewares/Middleware.d.ts.map +0 -1
  114. package/lib/middlewares/Middleware.js +0 -21
  115. package/lib/middlewares/Processor.d.ts +0 -9
  116. package/lib/middlewares/Processor.d.ts.map +0 -1
  117. package/lib/middlewares/Processor.js +0 -54
  118. package/lib/middlewares/TransactionContext.d.ts +0 -35
  119. package/lib/middlewares/TransactionContext.d.ts.map +0 -1
  120. package/lib/middlewares/TransactionContext.js +0 -90
  121. package/lib/middlewares/TransactoinProcessor.d.ts +0 -6
  122. package/lib/middlewares/TransactoinProcessor.d.ts.map +0 -1
  123. package/lib/middlewares/TransactoinProcessor.js +0 -17
  124. package/lib/middlewares/VisitObservedCallsMiddleware.d.ts +0 -7
  125. package/lib/middlewares/VisitObservedCallsMiddleware.d.ts.map +0 -1
  126. package/lib/middlewares/VisitObservedCallsMiddleware.js +0 -96
  127. package/lib/middlewares/VisitObservedSfusMiddleware.d.ts +0 -6
  128. package/lib/middlewares/VisitObservedSfusMiddleware.d.ts.map +0 -1
  129. package/lib/middlewares/VisitObservedSfusMiddleware.js +0 -151
  130. package/lib/middlewares/visitors/visitClient.d.ts +0 -5
  131. package/lib/middlewares/visitors/visitClient.d.ts.map +0 -1
  132. package/lib/middlewares/visitors/visitClient.js +0 -174
  133. package/lib/middlewares/visitors/visitInboundAudioTrack.d.ts +0 -5
  134. package/lib/middlewares/visitors/visitInboundAudioTrack.d.ts.map +0 -1
  135. package/lib/middlewares/visitors/visitInboundAudioTrack.js +0 -93
  136. package/lib/middlewares/visitors/visitInboundVideoTrack.d.ts +0 -5
  137. package/lib/middlewares/visitors/visitInboundVideoTrack.d.ts.map +0 -1
  138. package/lib/middlewares/visitors/visitInboundVideoTrack.js +0 -94
  139. package/lib/middlewares/visitors/visitOutboundAudioTrack.d.ts +0 -5
  140. package/lib/middlewares/visitors/visitOutboundAudioTrack.d.ts.map +0 -1
  141. package/lib/middlewares/visitors/visitOutboundAudioTrack.js +0 -90
  142. package/lib/middlewares/visitors/visitOutboundVideoTarck.d.ts +0 -5
  143. package/lib/middlewares/visitors/visitOutboundVideoTarck.d.ts.map +0 -1
  144. package/lib/middlewares/visitors/visitOutboundVideoTarck.js +0 -90
  145. package/lib/middlewares/visitors/visitPeerConnection.d.ts +0 -5
  146. package/lib/middlewares/visitors/visitPeerConnection.d.ts.map +0 -1
  147. package/lib/middlewares/visitors/visitPeerConnection.js +0 -111
  148. package/lib/middlewares/visitors/visitSfu.d.ts +0 -5
  149. package/lib/middlewares/visitors/visitSfu.d.ts.map +0 -1
  150. package/lib/middlewares/visitors/visitSfu.js +0 -78
  151. package/lib/middlewares/visitors/visitSfuInboundRtpPad.d.ts +0 -5
  152. package/lib/middlewares/visitors/visitSfuInboundRtpPad.d.ts.map +0 -1
  153. package/lib/middlewares/visitors/visitSfuInboundRtpPad.js +0 -56
  154. package/lib/middlewares/visitors/visitSfuOutboundRtpPad.d.ts +0 -5
  155. package/lib/middlewares/visitors/visitSfuOutboundRtpPad.d.ts.map +0 -1
  156. package/lib/middlewares/visitors/visitSfuOutboundRtpPad.js +0 -56
  157. package/lib/middlewares/visitors/visitSfuSctpChannel.d.ts +0 -5
  158. package/lib/middlewares/visitors/visitSfuSctpChannel.d.ts.map +0 -1
  159. package/lib/middlewares/visitors/visitSfuSctpChannel.js +0 -55
  160. package/lib/middlewares/visitors/visitSfuTransport.d.ts +0 -5
  161. package/lib/middlewares/visitors/visitSfuTransport.d.ts.map +0 -1
  162. package/lib/middlewares/visitors/visitSfuTransport.js +0 -56
  163. package/lib/processes/closePeerConnectionProcess.d.ts +0 -10
  164. package/lib/processes/closePeerConnectionProcess.d.ts.map +0 -1
  165. package/lib/processes/closePeerConnectionProcess.js +0 -51
  166. package/lib/processes/detachClientProcess.d.ts +0 -14
  167. package/lib/processes/detachClientProcess.d.ts.map +0 -1
  168. package/lib/processes/detachClientProcess.js +0 -106
  169. package/lib/processes/findRemoteMatches.d.ts +0 -9
  170. package/lib/processes/findRemoteMatches.d.ts.map +0 -1
  171. package/lib/processes/findRemoteMatches.js +0 -96
  172. package/lib/processes/inboundTrackRemoved.d.ts +0 -9
  173. package/lib/processes/inboundTrackRemoved.d.ts.map +0 -1
  174. package/lib/processes/inboundTrackRemoved.js +0 -22
  175. package/lib/processes/joinClientProcess.d.ts +0 -11
  176. package/lib/processes/joinClientProcess.d.ts.map +0 -1
  177. package/lib/processes/joinClientProcess.js +0 -120
  178. package/lib/processes/outboundTrackRemoved.d.ts +0 -9
  179. package/lib/processes/outboundTrackRemoved.d.ts.map +0 -1
  180. package/lib/processes/outboundTrackRemoved.js +0 -22
  181. package/lib/samples/ObservedCall.d.ts +0 -17
  182. package/lib/samples/ObservedCall.d.ts.map +0 -1
  183. package/lib/samples/ObservedCall.js +0 -29
  184. package/lib/samples/ObservedCalls.d.ts +0 -19
  185. package/lib/samples/ObservedCalls.d.ts.map +0 -1
  186. package/lib/samples/ObservedCalls.js +0 -113
  187. package/lib/samples/ObservedClient.d.ts +0 -28
  188. package/lib/samples/ObservedClient.d.ts.map +0 -1
  189. package/lib/samples/ObservedClient.js +0 -110
  190. package/lib/samples/ObservedInboundAudioTrack.d.ts +0 -17
  191. package/lib/samples/ObservedInboundAudioTrack.d.ts.map +0 -1
  192. package/lib/samples/ObservedInboundAudioTrack.js +0 -17
  193. package/lib/samples/ObservedInboundVideoTrack.d.ts +0 -17
  194. package/lib/samples/ObservedInboundVideoTrack.d.ts.map +0 -1
  195. package/lib/samples/ObservedInboundVideoTrack.js +0 -17
  196. package/lib/samples/ObservedOutboundAudioTrack.d.ts +0 -16
  197. package/lib/samples/ObservedOutboundAudioTrack.d.ts.map +0 -1
  198. package/lib/samples/ObservedOutboundAudioTrack.js +0 -17
  199. package/lib/samples/ObservedOutboundVideoTrack.d.ts +0 -16
  200. package/lib/samples/ObservedOutboundVideoTrack.d.ts.map +0 -1
  201. package/lib/samples/ObservedOutboundVideoTrack.js +0 -17
  202. package/lib/samples/ObservedPeerConnection.d.ts +0 -47
  203. package/lib/samples/ObservedPeerConnection.d.ts.map +0 -1
  204. package/lib/samples/ObservedPeerConnection.js +0 -130
  205. package/lib/samples/ObservedSfu.d.ts +0 -27
  206. package/lib/samples/ObservedSfu.d.ts.map +0 -1
  207. package/lib/samples/ObservedSfu.js +0 -65
  208. package/lib/samples/ObservedSfuInboundRtpPad.d.ts +0 -15
  209. package/lib/samples/ObservedSfuInboundRtpPad.d.ts.map +0 -1
  210. package/lib/samples/ObservedSfuInboundRtpPad.js +0 -17
  211. package/lib/samples/ObservedSfuOutboundRtpPad.d.ts +0 -15
  212. package/lib/samples/ObservedSfuOutboundRtpPad.d.ts.map +0 -1
  213. package/lib/samples/ObservedSfuOutboundRtpPad.js +0 -17
  214. package/lib/samples/ObservedSfuSctpChannel.d.ts +0 -15
  215. package/lib/samples/ObservedSfuSctpChannel.d.ts.map +0 -1
  216. package/lib/samples/ObservedSfuSctpChannel.js +0 -17
  217. package/lib/samples/ObservedSfuTransport.d.ts +0 -30
  218. package/lib/samples/ObservedSfuTransport.d.ts.map +0 -1
  219. package/lib/samples/ObservedSfuTransport.js +0 -86
  220. package/lib/samples/ObservedSfus.d.ts +0 -16
  221. package/lib/samples/ObservedSfus.d.ts.map +0 -1
  222. package/lib/samples/ObservedSfus.js +0 -72
  223. package/lib/sinks/ObserverSink.d.ts.map +0 -1
  224. package/lib/sinks/callEventReports.d.ts.map +0 -1
  225. package/lib/sources/ObservedCallSource.d.ts +0 -18
  226. package/lib/sources/ObservedCallSource.d.ts.map +0 -1
  227. package/lib/sources/ObservedCallSource.js +0 -2
  228. package/lib/sources/ObservedClientSource.d.ts +0 -19
  229. package/lib/sources/ObservedClientSource.d.ts.map +0 -1
  230. package/lib/sources/ObservedClientSource.js +0 -2
  231. package/lib/sources/ObservedSfuSource.d.ts +0 -15
  232. package/lib/sources/ObservedSfuSource.d.ts.map +0 -1
  233. package/lib/sources/ObservedSfuSource.js +0 -2
  234. package/lib/sources/Sources.d.ts +0 -49
  235. package/lib/sources/Sources.d.ts.map +0 -1
  236. package/lib/sources/Sources.js +0 -213
  237. package/src/Evaluator.ts +0 -229
  238. package/src/common/Semaphore.ts +0 -45
  239. package/src/entries/CallEntry.ts +0 -62
  240. package/src/entries/ClientEntry.ts +0 -106
  241. package/src/entries/InboundTrackEntry.ts +0 -74
  242. package/src/entries/OutboundTrackEntry.ts +0 -72
  243. package/src/entries/PeerConnectionEntry.ts +0 -133
  244. package/src/entries/SfuEntry.ts +0 -62
  245. package/src/entries/SfuInboundRtpPadEntry.ts +0 -46
  246. package/src/entries/SfuOutboundRtpPadEntry.ts +0 -44
  247. package/src/entries/SfuSctpChannelEntry.ts +0 -39
  248. package/src/entries/SfuTransportEntry.ts +0 -109
  249. package/src/evaluators/SetClientsCoordinateEvaluator.ts +0 -78
  250. package/src/middlewares/CallOperationsContext.ts +0 -56
  251. package/src/middlewares/CallProcessor.ts +0 -38
  252. package/src/middlewares/CommitTransactionMiddleware.ts +0 -328
  253. package/src/middlewares/DeleteOutdatedCallEntries.ts +0 -159
  254. package/src/middlewares/DeleteOutdatedSfuEntries.ts +0 -168
  255. package/src/middlewares/Middleware.ts +0 -10
  256. package/src/middlewares/Processor.ts +0 -59
  257. package/src/middlewares/TransactionContext.ts +0 -176
  258. package/src/middlewares/TransactoinProcessor.ts +0 -28
  259. package/src/middlewares/VisitObservedCallsMiddleware.ts +0 -172
  260. package/src/middlewares/VisitObservedSfusMiddleware.ts +0 -203
  261. package/src/middlewares/visitors/visitClient.ts +0 -239
  262. package/src/middlewares/visitors/visitInboundAudioTrack.ts +0 -113
  263. package/src/middlewares/visitors/visitInboundVideoTrack.ts +0 -117
  264. package/src/middlewares/visitors/visitOutboundAudioTrack.ts +0 -100
  265. package/src/middlewares/visitors/visitOutboundVideoTarck.ts +0 -102
  266. package/src/middlewares/visitors/visitPeerConnection.ts +0 -151
  267. package/src/middlewares/visitors/visitSfu.ts +0 -70
  268. package/src/middlewares/visitors/visitSfuInboundRtpPad.ts +0 -52
  269. package/src/middlewares/visitors/visitSfuOutboundRtpPad.ts +0 -53
  270. package/src/middlewares/visitors/visitSfuSctpChannel.ts +0 -50
  271. package/src/middlewares/visitors/visitSfuTransport.ts +0 -50
  272. package/src/processes/closePeerConnectionProcess.ts +0 -54
  273. package/src/processes/detachClientProcess.ts +0 -136
  274. package/src/processes/findRemoteMatches.ts +0 -104
  275. package/src/processes/inboundTrackRemoved.ts +0 -22
  276. package/src/processes/joinClientProcess.ts +0 -138
  277. package/src/processes/outboundTrackRemoved.ts +0 -22
  278. package/src/samples/ObservedCall.ts +0 -49
  279. package/src/samples/ObservedCalls.ts +0 -143
  280. package/src/samples/ObservedClient.ts +0 -172
  281. package/src/samples/ObservedInboundAudioTrack.ts +0 -35
  282. package/src/samples/ObservedInboundVideoTrack.ts +0 -36
  283. package/src/samples/ObservedOutboundAudioTrack.ts +0 -35
  284. package/src/samples/ObservedOutboundVideoTrack.ts +0 -35
  285. package/src/samples/ObservedPeerConnection.ts +0 -227
  286. package/src/samples/ObservedSfu.ts +0 -115
  287. package/src/samples/ObservedSfuInboundRtpPad.ts +0 -35
  288. package/src/samples/ObservedSfuOutboundRtpPad.ts +0 -35
  289. package/src/samples/ObservedSfuSctpChannel.ts +0 -35
  290. package/src/samples/ObservedSfuTransport.ts +0 -142
  291. package/src/samples/ObservedSfus.ts +0 -95
  292. package/src/sources/ObservedCallSource.ts +0 -26
  293. package/src/sources/ObservedClientSource.ts +0 -28
  294. package/src/sources/ObservedSfuSource.ts +0 -19
  295. package/src/sources/Sources.ts +0 -301
  296. /package/lib/{sinks → common}/callEventReports.d.ts +0 -0
  297. /package/lib/{sinks → common}/callEventReports.js +0 -0
  298. /package/src/{sinks → common}/callEventReports.ts +0 -0
package/lib/Observer.js CHANGED
@@ -8,68 +8,21 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
9
  });
10
10
  };
11
- var __rest = (this && this.__rest) || function (s, e) {
12
- var t = {};
13
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
14
- t[p] = s[p];
15
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
16
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
17
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
18
- t[p[i]] = s[p[i]];
19
- }
20
- return t;
21
- };
22
- var __asyncValues = (this && this.__asyncValues) || function (o) {
23
- if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
24
- var m = o[Symbol.asyncIterator], i;
25
- return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
26
- function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
27
- function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
28
- };
29
- var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); }
30
- var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {
31
- if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
32
- var g = generator.apply(thisArg, _arguments || []), i, q = [];
33
- return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
34
- function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
35
- function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
36
- function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
37
- function fulfill(value) { resume("next", value); }
38
- function reject(value) { resume("throw", value); }
39
- function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
40
- };
41
11
  Object.defineProperty(exports, "__esModule", { value: true });
42
12
  exports.Observer = void 0;
43
- const ObserverSink_1 = require("./sinks/ObserverSink");
44
- const Sources_1 = require("./sources/Sources");
45
- const StorageProvider_1 = require("./storages/StorageProvider");
46
- const Evaluator_1 = require("./Evaluator");
47
- const Semaphore_1 = require("./common/Semaphore");
48
- const utils_1 = require("./common/utils");
49
13
  const logger_1 = require("./common/logger");
14
+ const StorageProvider_1 = require("./storages/StorageProvider");
15
+ const ObservedCall_1 = require("./ObservedCall");
16
+ const ReportsCollector_1 = require("./ReportsCollector");
50
17
  const events_1 = require("events");
51
- const CallEntry_1 = require("./entries/CallEntry");
52
- const ClientEntry_1 = require("./entries/ClientEntry");
53
- const PeerConnectionEntry_1 = require("./entries/PeerConnectionEntry");
54
- const InboundTrackEntry_1 = require("./entries/InboundTrackEntry");
55
- const OutboundTrackEntry_1 = require("./entries/OutboundTrackEntry");
56
- const SfuEntry_1 = require("./entries/SfuEntry");
57
- const SfuTransportEntry_1 = require("./entries/SfuTransportEntry");
58
- const SfuInboundRtpPadEntry_1 = require("./entries/SfuInboundRtpPadEntry");
59
- const SfuOutboundRtpPadEntry_1 = require("./entries/SfuOutboundRtpPadEntry");
60
- const SfuSctpChannelEntry_1 = require("./entries/SfuSctpChannelEntry");
61
- const SetClientsCoordinateEvaluator_1 = require("./evaluators/SetClientsCoordinateEvaluator");
18
+ const callEventReports_1 = require("./common/callEventReports");
62
19
  const logger = (0, logger_1.createLogger)('Observer');
63
- class Observer {
20
+ class Observer extends events_1.EventEmitter {
64
21
  static create(providedConfig) {
65
- var _a, _b;
22
+ var _a;
66
23
  const config = Object.assign({
67
24
  defaultServiceId: 'default-service-id',
68
25
  defaultMediaUnitId: 'default-media-unit-id',
69
- sources: {
70
- maxSamples: 1000,
71
- maxTimeInMs: 10000,
72
- },
73
26
  evaluator: {
74
27
  fetchSamples: true,
75
28
  maxIdleTimeInMs: 300 * 1000,
@@ -77,566 +30,49 @@ class Observer {
77
30
  sink: {},
78
31
  logLevel: 'info',
79
32
  }, providedConfig);
80
- const semaphores = (_a = providedConfig.semaphores) !== null && _a !== void 0 ? _a : (0, Semaphore_1.createSimpleSemaphoreProvider)();
81
- const storages = (_b = providedConfig.storages) !== null && _b !== void 0 ? _b : (0, StorageProvider_1.createSimpleStorageProvider)();
82
- return new Observer(config, storages, semaphores);
33
+ const storages = (_a = providedConfig.storages) !== null && _a !== void 0 ? _a : (0, StorageProvider_1.createSimpleStorageProvider)();
34
+ return new Observer(config, storages);
83
35
  }
84
- constructor(config, _storages, _semaphores) {
36
+ constructor(config, storage) {
37
+ super();
85
38
  this.config = config;
86
- this._storages = _storages;
87
- this._semaphores = _semaphores;
88
- this._emitter = new events_1.EventEmitter();
39
+ this.storage = storage;
40
+ this.reports = new ReportsCollector_1.ReportsCollector();
41
+ this._observedCalls = new Map();
89
42
  this._closed = false;
90
- this._sources = new Sources_1.Sources(config.sources);
91
- this._sink = new ObserverSink_1.SinkImpl(config.sink);
92
- this._evaluator = new Evaluator_1.Evaluator(this.config.evaluator, this._semaphores.callSemaphore, this._storages, this._sink);
93
- this._sources.on('observed-samples', (event) => {
94
- this._emitter.emit('processing-started');
95
- this._evaluator.addObservedSamples(event);
96
- });
97
- this._sources.on('added-client-source', (event) => {
98
- this._evaluator.addCreatedClientSource(event);
99
- this._emitter.emit('client-added', event.clientId);
100
- });
101
- this._sources.on('removed-client-source', (event) => {
102
- this._evaluator.addClosedClientSource(event);
103
- this._emitter.emit('client-added', event.clientId);
104
- });
105
- this._evaluator.on('ready', () => {
106
- this._sink.emit();
107
- this._emitter.emit('processing-ended');
108
- });
109
43
  logger.debug('Observer is created with config', this.config);
44
+ const onNewReport = (collectedReports) => {
45
+ if (!this.config.maxReports || this._closed)
46
+ return;
47
+ if (this.config.maxReports < collectedReports) {
48
+ this._emitReports();
49
+ }
50
+ };
51
+ this.once('close', () => this.reports.off('newreport', onNewReport));
52
+ this.reports.on('newreport', onNewReport);
110
53
  }
111
- get sources() {
112
- return this._sources;
113
- }
114
- on(event, listener) {
115
- this._emitter.on(event, listener);
116
- return this;
117
- }
118
- once(event, listener) {
119
- this._emitter.once(event, listener);
120
- return this;
121
- }
122
- off(event, listener) {
123
- this._emitter.off(event, listener);
124
- return this;
125
- }
126
- createCallSource(config) {
127
- if (this._closed) {
128
- throw new Error('Attempted to create a call source on a closed observer');
129
- }
130
- const { serviceId = this.config.defaultServiceId, mediaUnitId = this.config.defaultMediaUnitId, appData = {} } = config, callConfig = __rest(config, ["serviceId", "mediaUnitId", "appData"]);
131
- return this._sources.createCallSource(Object.assign(Object.assign({}, callConfig), { appData,
132
- mediaUnitId,
133
- serviceId }));
134
- }
135
- createSfuSource(config) {
136
- if (this._closed) {
137
- throw new Error('Attempted to create a sfu source on a closed observer');
138
- }
139
- const { appData = {}, serviceId = this.config.defaultServiceId, mediaUnitId = this.config.defaultMediaUnitId, joined = Date.now() } = config, sfuConfig = __rest(config, ["appData", "serviceId", "mediaUnitId", "joined"]);
140
- return this._sources.createSfuSource(Object.assign(Object.assign({}, sfuConfig), { appData,
141
- serviceId,
142
- mediaUnitId,
143
- joined }));
144
- }
145
- evaluate() {
146
- return __awaiter(this, void 0, void 0, function* () {
147
- return new Promise((resolve, reject) => {
148
- this._evaluator.once('ready', (err) => {
149
- if (err)
150
- reject(err);
151
- else
152
- resolve();
153
- });
154
- this._sources.emitSamples();
155
- });
156
- });
157
- }
158
- get reports() {
159
- return this._sink;
160
- }
161
- addEvaluators(...processes) {
162
- if (this._closed) {
163
- throw new Error('Attempted to add an evaluator to a closed observer');
164
- }
165
- for (const process of processes) {
166
- this._evaluator.addProcess(process);
167
- }
168
- }
169
- removeEvaluators(...processes) {
170
- if (this._closed) {
171
- throw new Error('Attempted to remove an evaluator from a closed observer');
172
- }
173
- for (const process of processes) {
174
- this._evaluator.removeProcess(process);
175
- }
176
- }
177
- addCoordinateEvaluator(getClientCoordinate) {
178
- if (this._closed) {
179
- throw new Error('Attempted to add an evaluator to a closed observer');
180
- }
181
- const process = (0, SetClientsCoordinateEvaluator_1.createSetClientsCoordinateEvaluator)(getClientCoordinate);
182
- this._evaluator.addProcess((context) => __awaiter(this, void 0, void 0, function* () { return process(context); }));
183
- }
184
- addSinks(...processes) {
185
- if (this._closed) {
186
- throw new Error('Attempted to add an evaluator to a closed observer');
187
- }
188
- for (const process of processes) {
189
- this._sink.addProcess(process);
190
- }
191
- }
192
- removeSinks(...processes) {
193
- if (this._closed) {
194
- throw new Error('Attempted to remove an evaluator from a closed observer');
195
- }
196
- for (const process of processes) {
197
- this._sink.removeProcess(process);
198
- }
199
- }
200
- calls() {
201
- const storageProvider = this._storages;
202
- return (0, utils_1.asyncIteratorConverter)((function () {
203
- return __asyncGenerator(this, arguments, function* () {
204
- var _a, e_1, _b, _c;
205
- try {
206
- for (var _d = true, _e = __asyncValues(storageProvider.callStorage[Symbol.asyncIterator]()), _f; _f = yield __await(_e.next()), _a = _f.done, !_a;) {
207
- _c = _f.value;
208
- _d = false;
209
- try {
210
- const [, callModel] = _c;
211
- if (!callModel)
212
- continue;
213
- yield yield __await((0, CallEntry_1.createCallEntry)(storageProvider, callModel));
214
- }
215
- finally {
216
- _d = true;
217
- }
218
- }
219
- }
220
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
221
- finally {
222
- try {
223
- if (!_d && !_a && (_b = _e.return)) yield __await(_b.call(_e));
224
- }
225
- finally { if (e_1) throw e_1.error; }
226
- }
227
- });
228
- })());
229
- }
230
- sfus() {
231
- const storageProvider = this._storages;
232
- return (0, utils_1.asyncIteratorConverter)((function () {
233
- return __asyncGenerator(this, arguments, function* () {
234
- var _a, e_2, _b, _c;
235
- try {
236
- for (var _d = true, _e = __asyncValues(storageProvider.sfuStorage[Symbol.asyncIterator]()), _f; _f = yield __await(_e.next()), _a = _f.done, !_a;) {
237
- _c = _f.value;
238
- _d = false;
239
- try {
240
- const [, sfuModel] = _c;
241
- if (!sfuModel)
242
- continue;
243
- yield yield __await((0, SfuEntry_1.createSfuEntry)(storageProvider, sfuModel));
244
- }
245
- finally {
246
- _d = true;
247
- }
248
- }
249
- }
250
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
251
- finally {
252
- try {
253
- if (!_d && !_a && (_b = _e.return)) yield __await(_b.call(_e));
254
- }
255
- finally { if (e_2) throw e_2.error; }
256
- }
257
- });
258
- })());
259
- }
260
- sfuTransports() {
261
- const storageProvider = this._storages;
262
- return (0, utils_1.asyncIteratorConverter)((function () {
263
- return __asyncGenerator(this, arguments, function* () {
264
- var _a, e_3, _b, _c;
265
- try {
266
- for (var _d = true, _e = __asyncValues(storageProvider.sfuTransportStorage[Symbol.asyncIterator]()), _f; _f = yield __await(_e.next()), _a = _f.done, !_a;) {
267
- _c = _f.value;
268
- _d = false;
269
- try {
270
- const [, sfuTransportModel] = _c;
271
- if (!sfuTransportModel)
272
- continue;
273
- yield yield __await((0, SfuTransportEntry_1.createSfuTransportEntry)(storageProvider, sfuTransportModel));
274
- }
275
- finally {
276
- _d = true;
277
- }
278
- }
279
- }
280
- catch (e_3_1) { e_3 = { error: e_3_1 }; }
281
- finally {
282
- try {
283
- if (!_d && !_a && (_b = _e.return)) yield __await(_b.call(_e));
284
- }
285
- finally { if (e_3) throw e_3.error; }
286
- }
287
- });
288
- })());
289
- }
290
- sfuInboundRtpPads() {
291
- const storageProvider = this._storages;
292
- return (0, utils_1.asyncIteratorConverter)((function () {
293
- return __asyncGenerator(this, arguments, function* () {
294
- var _a, e_4, _b, _c;
295
- try {
296
- for (var _d = true, _e = __asyncValues(storageProvider.sfuInboundRtpPadStorage[Symbol.asyncIterator]()), _f; _f = yield __await(_e.next()), _a = _f.done, !_a;) {
297
- _c = _f.value;
298
- _d = false;
299
- try {
300
- const [, sfuInboundRtpPadModel] = _c;
301
- if (!sfuInboundRtpPadModel)
302
- continue;
303
- yield yield __await((0, SfuInboundRtpPadEntry_1.createSfuInboundRtpPadEntry)(storageProvider, sfuInboundRtpPadModel));
304
- }
305
- finally {
306
- _d = true;
307
- }
308
- }
309
- }
310
- catch (e_4_1) { e_4 = { error: e_4_1 }; }
311
- finally {
312
- try {
313
- if (!_d && !_a && (_b = _e.return)) yield __await(_b.call(_e));
314
- }
315
- finally { if (e_4) throw e_4.error; }
316
- }
317
- });
318
- })());
319
- }
320
- sfuOutboundRtpPads() {
321
- const storageProvider = this._storages;
322
- return (0, utils_1.asyncIteratorConverter)((function () {
323
- return __asyncGenerator(this, arguments, function* () {
324
- var _a, e_5, _b, _c;
325
- try {
326
- for (var _d = true, _e = __asyncValues(storageProvider.sfuOutboundRtpPadStorage[Symbol.asyncIterator]()), _f; _f = yield __await(_e.next()), _a = _f.done, !_a;) {
327
- _c = _f.value;
328
- _d = false;
329
- try {
330
- const [, sfuOutboundRtpPadModel] = _c;
331
- if (!sfuOutboundRtpPadModel)
332
- continue;
333
- yield yield __await((0, SfuOutboundRtpPadEntry_1.createSfuOutboundRtpPadEntry)(storageProvider, sfuOutboundRtpPadModel));
334
- }
335
- finally {
336
- _d = true;
337
- }
338
- }
339
- }
340
- catch (e_5_1) { e_5 = { error: e_5_1 }; }
341
- finally {
342
- try {
343
- if (!_d && !_a && (_b = _e.return)) yield __await(_b.call(_e));
344
- }
345
- finally { if (e_5) throw e_5.error; }
346
- }
347
- });
348
- })());
349
- }
350
- clients() {
351
- const storageProvider = this._storages;
352
- return (0, utils_1.asyncIteratorConverter)((function () {
353
- return __asyncGenerator(this, arguments, function* () {
354
- var _a, e_6, _b, _c;
355
- try {
356
- for (var _d = true, _e = __asyncValues(storageProvider.clientStorage[Symbol.asyncIterator]()), _f; _f = yield __await(_e.next()), _a = _f.done, !_a;) {
357
- _c = _f.value;
358
- _d = false;
359
- try {
360
- const [, callModel] = _c;
361
- if (!callModel)
362
- continue;
363
- yield yield __await((0, ClientEntry_1.createClientEntry)(storageProvider, callModel));
364
- }
365
- finally {
366
- _d = true;
367
- }
368
- }
369
- }
370
- catch (e_6_1) { e_6 = { error: e_6_1 }; }
371
- finally {
372
- try {
373
- if (!_d && !_a && (_b = _e.return)) yield __await(_b.call(_e));
374
- }
375
- finally { if (e_6) throw e_6.error; }
376
- }
377
- });
378
- })());
379
- }
380
- peerConnections() {
381
- const storageProvider = this._storages;
382
- return (0, utils_1.asyncIteratorConverter)((function () {
383
- return __asyncGenerator(this, arguments, function* () {
384
- var _a, e_7, _b, _c;
385
- try {
386
- for (var _d = true, _e = __asyncValues(storageProvider.peerConnectionStorage[Symbol.asyncIterator]()), _f; _f = yield __await(_e.next()), _a = _f.done, !_a;) {
387
- _c = _f.value;
388
- _d = false;
389
- try {
390
- const [, peerConnectionModel] = _c;
391
- if (!peerConnectionModel)
392
- continue;
393
- yield yield __await((0, PeerConnectionEntry_1.createPeerConnectionEntry)(storageProvider, peerConnectionModel));
394
- }
395
- finally {
396
- _d = true;
397
- }
398
- }
399
- }
400
- catch (e_7_1) { e_7 = { error: e_7_1 }; }
401
- finally {
402
- try {
403
- if (!_d && !_a && (_b = _e.return)) yield __await(_b.call(_e));
404
- }
405
- finally { if (e_7) throw e_7.error; }
406
- }
407
- });
408
- })());
409
- }
410
- getTrack(trackId) {
411
- return __awaiter(this, void 0, void 0, function* () {
412
- const { inboundTrackStorage, outboundTrackStorage } = this._storages;
413
- const [inbTrackModel, outbTrackModel] = yield Promise.all([
414
- inboundTrackStorage.get(trackId),
415
- outboundTrackStorage.get(trackId),
416
- ]);
417
- if (inbTrackModel)
418
- return (0, InboundTrackEntry_1.createInboundTrackEntry)(this._storages, inbTrackModel);
419
- else if (outbTrackModel)
420
- return (0, OutboundTrackEntry_1.createOutboundTrackEntry)(this._storages, outbTrackModel);
421
- });
422
- }
423
- getAllTracks(trackIds) {
54
+ createObservedCall(config) {
424
55
  return __awaiter(this, void 0, void 0, function* () {
425
- const storageProvider = this._storages;
426
- const { inboundTrackStorage, outboundTrackStorage } = this._storages;
427
- const [inbTrackModels, outbTrackModels] = yield Promise.all([
428
- inboundTrackStorage.getAll(trackIds),
429
- outboundTrackStorage.getAll(trackIds),
430
- ]);
431
- const result = new Map();
432
- for (const [trackId, model] of inbTrackModels) {
433
- result.set(trackId, (0, InboundTrackEntry_1.createInboundTrackEntry)(storageProvider, model));
434
- }
435
- for (const [trackId, model] of outbTrackModels) {
436
- result.set(trackId, (0, OutboundTrackEntry_1.createOutboundTrackEntry)(storageProvider, model));
56
+ if (this._closed) {
57
+ throw new Error('Attempted to create a call source on a closed observer');
437
58
  }
438
- return result;
439
- });
440
- }
441
- inboundTracks() {
442
- const storageProvider = this._storages;
443
- return (0, utils_1.asyncIteratorConverter)((function () {
444
- return __asyncGenerator(this, arguments, function* () {
445
- var _a, e_8, _b, _c;
446
- try {
447
- for (var _d = true, _e = __asyncValues(storageProvider.inboundTrackStorage[Symbol.asyncIterator]()), _f; _f = yield __await(_e.next()), _a = _f.done, !_a;) {
448
- _c = _f.value;
449
- _d = false;
450
- try {
451
- const [, inboundTrackModel] = _c;
452
- if (!inboundTrackModel)
453
- continue;
454
- yield yield __await((0, InboundTrackEntry_1.createInboundTrackEntry)(storageProvider, inboundTrackModel));
455
- }
456
- finally {
457
- _d = true;
458
- }
459
- }
460
- }
461
- catch (e_8_1) { e_8 = { error: e_8_1 }; }
462
- finally {
463
- try {
464
- if (!_d && !_a && (_b = _e.return)) yield __await(_b.call(_e));
465
- }
466
- finally { if (e_8) throw e_8.error; }
467
- }
59
+ const call = yield ObservedCall_1.ObservedCall.create(Object.assign({ serviceId: this.config.defaultServiceId, started: Date.now() }, config), this);
60
+ if (this._closed)
61
+ throw new Error('Cannot create an observed call on a closed observer');
62
+ if (this._observedCalls.has(call.callId))
63
+ throw new Error(`Observed Call with id ${call.callId} already exists`);
64
+ call.once('close', () => {
65
+ this._observedCalls.delete(call.callId);
66
+ this.reports.addCallEventReport((0, callEventReports_1.createCallStartedEventReport)(call.serviceId, call.roomId, call.callId, Date.now()));
468
67
  });
469
- })());
470
- }
471
- outboundTracks() {
472
- const storageProvider = this._storages;
473
- return (0, utils_1.asyncIteratorConverter)((function () {
474
- return __asyncGenerator(this, arguments, function* () {
475
- var _a, e_9, _b, _c;
476
- try {
477
- for (var _d = true, _e = __asyncValues(storageProvider.outboundTrackStorage[Symbol.asyncIterator]()), _f; _f = yield __await(_e.next()), _a = _f.done, !_a;) {
478
- _c = _f.value;
479
- _d = false;
480
- try {
481
- const [, outboundTrackModel] = _c;
482
- if (!outboundTrackModel)
483
- continue;
484
- yield yield __await((0, OutboundTrackEntry_1.createOutboundTrackEntry)(storageProvider, outboundTrackModel));
485
- }
486
- finally {
487
- _d = true;
488
- }
489
- }
490
- }
491
- catch (e_9_1) { e_9 = { error: e_9_1 }; }
492
- finally {
493
- try {
494
- if (!_d && !_a && (_b = _e.return)) yield __await(_b.call(_e));
495
- }
496
- finally { if (e_9) throw e_9.error; }
497
- }
498
- });
499
- })());
500
- }
501
- sfuSctpChannels() {
502
- const storageProvider = this._storages;
503
- return (0, utils_1.asyncIteratorConverter)((function () {
504
- return __asyncGenerator(this, arguments, function* () {
505
- var _a, e_10, _b, _c;
506
- try {
507
- for (var _d = true, _e = __asyncValues(storageProvider.sfuSctpChannelStorage[Symbol.asyncIterator]()), _f; _f = yield __await(_e.next()), _a = _f.done, !_a;) {
508
- _c = _f.value;
509
- _d = false;
510
- try {
511
- const [, sfuSctpChannelModel] = _c;
512
- if (!sfuSctpChannelModel)
513
- continue;
514
- yield yield __await((0, SfuSctpChannelEntry_1.createSfuSctpChannelEntry)(storageProvider, sfuSctpChannelModel));
515
- }
516
- finally {
517
- _d = true;
518
- }
519
- }
520
- }
521
- catch (e_10_1) { e_10 = { error: e_10_1 }; }
522
- finally {
523
- try {
524
- if (!_d && !_a && (_b = _e.return)) yield __await(_b.call(_e));
525
- }
526
- finally { if (e_10) throw e_10.error; }
527
- }
528
- });
529
- })());
530
- }
531
- getCall(callId) {
532
- return __awaiter(this, void 0, void 0, function* () {
533
- return (0, CallEntry_1.createCallEntry)(this._storages, yield this._storages.callStorage.get(callId));
534
- });
535
- }
536
- getAllCalls(callIds) {
537
- return __awaiter(this, void 0, void 0, function* () {
538
- const models = yield this._storages.callStorage.getAll(callIds);
539
- return new Map(Array.from(models).map(([callId, model]) => [callId, (0, CallEntry_1.createCallEntry)(this._storages, model)]));
68
+ this._observedCalls.set(call.callId, call);
69
+ this.reports.addCallEventReport((0, callEventReports_1.createCallStartedEventReport)(call.serviceId, call.roomId, call.callId, call.started));
70
+ this.emit('newcall', call);
71
+ return call;
540
72
  });
541
73
  }
542
- getSfu(sfuId) {
543
- return __awaiter(this, void 0, void 0, function* () {
544
- return (0, SfuEntry_1.createSfuEntry)(this._storages, yield this._storages.sfuStorage.get(sfuId));
545
- });
546
- }
547
- getAllSfus(sfuIds) {
548
- return __awaiter(this, void 0, void 0, function* () {
549
- const models = yield this._storages.sfuStorage.getAll(sfuIds);
550
- return new Map(Array.from(models).map(([sfuId, model]) => [sfuId, (0, SfuEntry_1.createSfuEntry)(this._storages, model)]));
551
- });
552
- }
553
- getSfuTransport(sfuTransportId) {
554
- return __awaiter(this, void 0, void 0, function* () {
555
- return (0, SfuTransportEntry_1.createSfuTransportEntry)(this._storages, yield this._storages.sfuTransportStorage.get(sfuTransportId));
556
- });
557
- }
558
- getAllSfuTransports(sfuTransportIds) {
559
- return __awaiter(this, void 0, void 0, function* () {
560
- const models = yield this._storages.sfuTransportStorage.getAll(sfuTransportIds);
561
- return new Map(Array.from(models).map(([sfuTransportId, model]) => [sfuTransportId, (0, SfuTransportEntry_1.createSfuTransportEntry)(this._storages, model)]));
562
- });
563
- }
564
- getSfuInboundRtpPad(sfuInboundRtpPadId) {
565
- return __awaiter(this, void 0, void 0, function* () {
566
- return (0, SfuInboundRtpPadEntry_1.createSfuInboundRtpPadEntry)(this._storages, yield this._storages.sfuInboundRtpPadStorage.get(sfuInboundRtpPadId));
567
- });
568
- }
569
- getAllSfuInboundRtpPads(sfuInboundRtpPadIds) {
570
- return __awaiter(this, void 0, void 0, function* () {
571
- const models = yield this._storages.sfuInboundRtpPadStorage.getAll(sfuInboundRtpPadIds);
572
- return new Map(Array.from(models).map(([sfuInboundRtpPadId, model]) => [sfuInboundRtpPadId, (0, SfuInboundRtpPadEntry_1.createSfuInboundRtpPadEntry)(this._storages, model)]));
573
- });
574
- }
575
- getSfuOutboundRtpPad(sfuOutboundRtpPadId) {
576
- return __awaiter(this, void 0, void 0, function* () {
577
- return (0, SfuOutboundRtpPadEntry_1.createSfuOutboundRtpPadEntry)(this._storages, yield this._storages.sfuOutboundRtpPadStorage.get(sfuOutboundRtpPadId));
578
- });
579
- }
580
- getAllSfuOutboundRtpPads(sfuOutboundRtpPadIds) {
581
- return __awaiter(this, void 0, void 0, function* () {
582
- const models = yield this._storages.sfuOutboundRtpPadStorage.getAll(sfuOutboundRtpPadIds);
583
- return new Map(Array.from(models).map(([sfuOutboundRtpPadId, model]) => [sfuOutboundRtpPadId, (0, SfuOutboundRtpPadEntry_1.createSfuOutboundRtpPadEntry)(this._storages, model)]));
584
- });
585
- }
586
- getClient(clientId) {
587
- return __awaiter(this, void 0, void 0, function* () {
588
- return (0, ClientEntry_1.createClientEntry)(this._storages, yield this._storages.clientStorage.get(clientId));
589
- });
590
- }
591
- getAllClient(clientIds) {
592
- return __awaiter(this, void 0, void 0, function* () {
593
- const models = yield this._storages.clientStorage.getAll(clientIds);
594
- return new Map(Array.from(models).map(([clientId, model]) => [clientId, (0, ClientEntry_1.createClientEntry)(this._storages, model)]));
595
- });
596
- }
597
- getPeerConnection(peerConnectionId) {
598
- return __awaiter(this, void 0, void 0, function* () {
599
- return (0, PeerConnectionEntry_1.createPeerConnectionEntry)(this._storages, yield this._storages.peerConnectionStorage.get(peerConnectionId));
600
- });
601
- }
602
- getAllPeerConnections(peerConnectionIds) {
603
- return __awaiter(this, void 0, void 0, function* () {
604
- const models = yield this._storages.peerConnectionStorage.getAll(peerConnectionIds);
605
- return new Map(Array.from(models).map(([peerConnectionId, model]) => [peerConnectionId, (0, PeerConnectionEntry_1.createPeerConnectionEntry)(this._storages, model)]));
606
- });
607
- }
608
- getInboundTrack(inboundTrackId) {
609
- return __awaiter(this, void 0, void 0, function* () {
610
- return (0, InboundTrackEntry_1.createInboundTrackEntry)(this._storages, yield this._storages.inboundTrackStorage.get(inboundTrackId));
611
- });
612
- }
613
- getAllInboundTracks(inboundTrackIds) {
614
- return __awaiter(this, void 0, void 0, function* () {
615
- const models = yield this._storages.inboundTrackStorage.getAll(inboundTrackIds);
616
- return new Map(Array.from(models).map(([inboundTrackId, model]) => [inboundTrackId, (0, InboundTrackEntry_1.createInboundTrackEntry)(this._storages, model)]));
617
- });
618
- }
619
- getOutboundTrack(outboundTrackId) {
620
- return __awaiter(this, void 0, void 0, function* () {
621
- return (0, OutboundTrackEntry_1.createOutboundTrackEntry)(this._storages, yield this._storages.outboundTrackStorage.get(outboundTrackId));
622
- });
623
- }
624
- getAllOutboundTracks(outboundTrackIds) {
625
- return __awaiter(this, void 0, void 0, function* () {
626
- const models = yield this._storages.outboundTrackStorage.getAll(outboundTrackIds);
627
- return new Map(Array.from(models).map(([outboundTrackId, model]) => [outboundTrackId, (0, OutboundTrackEntry_1.createOutboundTrackEntry)(this._storages, model)]));
628
- });
629
- }
630
- getSfuSctpChannel(sctpChannelId) {
631
- return __awaiter(this, void 0, void 0, function* () {
632
- return (0, SfuSctpChannelEntry_1.createSfuSctpChannelEntry)(this._storages, yield this._storages.sfuSctpChannelStorage.get(sctpChannelId));
633
- });
634
- }
635
- getAllSfuSctpChannel(sctpChannelIds) {
636
- return __awaiter(this, void 0, void 0, function* () {
637
- const models = yield this._storages.sfuSctpChannelStorage.getAll(sctpChannelIds);
638
- return new Map(Array.from(models).map(([sctpChannelId, model]) => [sctpChannelId, (0, SfuSctpChannelEntry_1.createSfuSctpChannelEntry)(this._storages, model)]));
639
- });
74
+ get observedCalls() {
75
+ return this._observedCalls;
640
76
  }
641
77
  get closed() {
642
78
  return this._closed;
@@ -646,8 +82,20 @@ class Observer {
646
82
  return logger.debug('Attempted to close twice');
647
83
  }
648
84
  this._closed = true;
649
- this._sources.close();
650
- this._emitter.emit('close');
85
+ this.emit('close');
86
+ }
87
+ _emitReports() {
88
+ if (this._reportTimer) {
89
+ clearTimeout(this._reportTimer);
90
+ this._reportTimer = undefined;
91
+ }
92
+ this.reports.emit();
93
+ if (this.config.maxCollectingTimeInMs) {
94
+ this._reportTimer = setTimeout(() => {
95
+ this._reportTimer = undefined;
96
+ this._emitReports();
97
+ }, this.config.maxCollectingTimeInMs);
98
+ }
651
99
  }
652
100
  }
653
101
  exports.Observer = Observer;