@observertc/observer-js 0.9.21-beta → 0.9.23-beta

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 (212) hide show
  1. package/.eslintrc.json +143 -0
  2. package/lib/Evaluator.d.ts.map +1 -1
  3. package/lib/Evaluator.js +54 -47
  4. package/lib/Observer.d.ts +1404 -38
  5. package/lib/Observer.d.ts.map +1 -1
  6. package/lib/Observer.js +479 -176
  7. package/lib/common/Semaphore.d.ts.map +1 -1
  8. package/lib/common/callMetaReports.d.ts.map +1 -1
  9. package/lib/common/callMetaReports.js +1 -0
  10. package/lib/common/logger.d.ts.map +1 -1
  11. package/lib/common/logger.js +15 -15
  12. package/lib/common/utils.d.ts +1 -0
  13. package/lib/common/utils.d.ts.map +1 -1
  14. package/lib/common/utils.js +12 -1
  15. package/lib/entries/CallEntry.d.ts +611 -0
  16. package/lib/entries/CallEntry.d.ts.map +1 -0
  17. package/lib/entries/CallEntry.js +75 -0
  18. package/lib/entries/ClientEntry.d.ts +474 -0
  19. package/lib/entries/ClientEntry.d.ts.map +1 -0
  20. package/lib/entries/ClientEntry.js +101 -0
  21. package/lib/entries/InboundTrackEntry.d.ts +670 -0
  22. package/lib/entries/InboundTrackEntry.d.ts.map +1 -0
  23. package/lib/entries/InboundTrackEntry.js +76 -0
  24. package/lib/entries/OutboundTrackEntry.d.ts +670 -0
  25. package/lib/entries/OutboundTrackEntry.d.ts.map +1 -0
  26. package/lib/entries/OutboundTrackEntry.js +73 -0
  27. package/lib/entries/PeerConnectionEntry.d.ts +469 -0
  28. package/lib/entries/PeerConnectionEntry.d.ts.map +1 -0
  29. package/lib/entries/PeerConnectionEntry.js +144 -0
  30. package/lib/entries/SfuEntry.d.ts +150 -0
  31. package/lib/entries/SfuEntry.d.ts.map +1 -0
  32. package/lib/entries/SfuEntry.js +77 -0
  33. package/lib/entries/SfuInboundRtpPadEntry.d.ts +14 -0
  34. package/lib/entries/SfuInboundRtpPadEntry.d.ts.map +1 -0
  35. package/lib/entries/SfuInboundRtpPadEntry.js +49 -0
  36. package/lib/entries/SfuOutboundRtpPadEntry.d.ts +14 -0
  37. package/lib/entries/SfuOutboundRtpPadEntry.d.ts.map +1 -0
  38. package/lib/entries/SfuOutboundRtpPadEntry.js +47 -0
  39. package/lib/entries/SfuSctpChannelEntry.d.ts +12 -0
  40. package/lib/entries/SfuSctpChannelEntry.d.ts.map +1 -0
  41. package/lib/entries/SfuSctpChannelEntry.js +43 -0
  42. package/lib/entries/SfuTransportEntry.d.ts +82 -0
  43. package/lib/entries/SfuTransportEntry.d.ts.map +1 -0
  44. package/lib/entries/SfuTransportEntry.js +122 -0
  45. package/lib/index.d.ts +10 -0
  46. package/lib/index.d.ts.map +1 -1
  47. package/lib/middlewares/CallOperationsContext.d.ts.map +1 -1
  48. package/lib/middlewares/CallOperationsContext.js +2 -6
  49. package/lib/middlewares/CallProcessor.d.ts.map +1 -1
  50. package/lib/middlewares/CallProcessor.js +15 -6
  51. package/lib/middlewares/CommitTransactionMiddleware.d.ts.map +1 -1
  52. package/lib/middlewares/CommitTransactionMiddleware.js +22 -26
  53. package/lib/middlewares/DeleteOutdatedCallEntries.d.ts.map +1 -1
  54. package/lib/middlewares/DeleteOutdatedCallEntries.js +29 -20
  55. package/lib/middlewares/DeleteOutdatedSfuEntries.d.ts.map +1 -1
  56. package/lib/middlewares/DeleteOutdatedSfuEntries.js +27 -18
  57. package/lib/middlewares/Middleware.d.ts.map +1 -1
  58. package/lib/middlewares/Middleware.js +13 -4
  59. package/lib/middlewares/Processor.d.ts.map +1 -1
  60. package/lib/middlewares/Processor.js +18 -9
  61. package/lib/middlewares/TransactionContext.d.ts.map +1 -1
  62. package/lib/middlewares/TransactionContext.js +84 -73
  63. package/lib/middlewares/VisitObservedCallsMiddleware.d.ts.map +1 -1
  64. package/lib/middlewares/VisitObservedCallsMiddleware.js +16 -7
  65. package/lib/middlewares/VisitObservedSfusMiddleware.d.ts.map +1 -1
  66. package/lib/middlewares/VisitObservedSfusMiddleware.js +15 -6
  67. package/lib/middlewares/visitors/visitClient.d.ts.map +1 -1
  68. package/lib/middlewares/visitors/visitClient.js +6 -18
  69. package/lib/middlewares/visitors/visitInboundAudioTrack.d.ts.map +1 -1
  70. package/lib/middlewares/visitors/visitInboundAudioTrack.js +17 -20
  71. package/lib/middlewares/visitors/visitInboundVideoTrack.d.ts.map +1 -1
  72. package/lib/middlewares/visitors/visitInboundVideoTrack.js +16 -21
  73. package/lib/middlewares/visitors/visitOutboundAudioTrack.d.ts.map +1 -1
  74. package/lib/middlewares/visitors/visitOutboundAudioTrack.js +16 -16
  75. package/lib/middlewares/visitors/visitOutboundVideoTarck.d.ts.map +1 -1
  76. package/lib/middlewares/visitors/visitOutboundVideoTarck.js +16 -17
  77. package/lib/middlewares/visitors/visitPeerConnection.d.ts.map +1 -1
  78. package/lib/middlewares/visitors/visitPeerConnection.js +24 -40
  79. package/lib/middlewares/visitors/visitSfu.d.ts.map +1 -1
  80. package/lib/middlewares/visitors/visitSfu.js +6 -7
  81. package/lib/middlewares/visitors/visitSfuInboundRtpPad.d.ts.map +1 -1
  82. package/lib/middlewares/visitors/visitSfuInboundRtpPad.js +3 -7
  83. package/lib/middlewares/visitors/visitSfuOutboundRtpPad.d.ts.map +1 -1
  84. package/lib/middlewares/visitors/visitSfuOutboundRtpPad.js +3 -8
  85. package/lib/middlewares/visitors/visitSfuSctpChannel.d.ts.map +1 -1
  86. package/lib/middlewares/visitors/visitSfuSctpChannel.js +3 -6
  87. package/lib/middlewares/visitors/visitSfuTransport.d.ts.map +1 -1
  88. package/lib/middlewares/visitors/visitSfuTransport.js +3 -6
  89. package/lib/processes/closePeerConnectionProcess.d.ts.map +1 -1
  90. package/lib/processes/closePeerConnectionProcess.js +14 -5
  91. package/lib/processes/detachClientProcess.d.ts.map +1 -1
  92. package/lib/processes/detachClientProcess.js +20 -17
  93. package/lib/processes/findRemoteMatches.d.ts +2 -2
  94. package/lib/processes/findRemoteMatches.d.ts.map +1 -1
  95. package/lib/processes/findRemoteMatches.js +70 -56
  96. package/lib/processes/inboundTrackRemoved.d.ts.map +1 -1
  97. package/lib/processes/inboundTrackRemoved.js +12 -3
  98. package/lib/processes/joinClientProcess.d.ts.map +1 -1
  99. package/lib/processes/joinClientProcess.js +15 -6
  100. package/lib/processes/outboundTrackRemoved.d.ts.map +1 -1
  101. package/lib/processes/outboundTrackRemoved.js +12 -3
  102. package/lib/samples/ObservedCall.d.ts.map +1 -1
  103. package/lib/samples/ObservedCall.js +1 -5
  104. package/lib/samples/ObservedCalls.d.ts.map +1 -1
  105. package/lib/samples/ObservedClient.d.ts.map +1 -1
  106. package/lib/samples/ObservedClient.js +1 -9
  107. package/lib/samples/ObservedInboundAudioTrack.d.ts.map +1 -1
  108. package/lib/samples/ObservedInboundAudioTrack.js +1 -5
  109. package/lib/samples/ObservedInboundVideoTrack.d.ts.map +1 -1
  110. package/lib/samples/ObservedInboundVideoTrack.js +1 -5
  111. package/lib/samples/ObservedOutboundAudioTrack.d.ts.map +1 -1
  112. package/lib/samples/ObservedOutboundAudioTrack.js +1 -5
  113. package/lib/samples/ObservedOutboundVideoTrack.d.ts.map +1 -1
  114. package/lib/samples/ObservedOutboundVideoTrack.js +1 -5
  115. package/lib/samples/ObservedPeerConnection.d.ts.map +1 -1
  116. package/lib/samples/ObservedPeerConnection.js +1 -12
  117. package/lib/samples/ObservedSfu.d.ts.map +1 -1
  118. package/lib/samples/ObservedSfu.js +1 -8
  119. package/lib/samples/ObservedSfuInboundRtpPad.d.ts.map +1 -1
  120. package/lib/samples/ObservedSfuInboundRtpPad.js +1 -5
  121. package/lib/samples/ObservedSfuOutboundRtpPad.d.ts.map +1 -1
  122. package/lib/samples/ObservedSfuOutboundRtpPad.js +1 -5
  123. package/lib/samples/ObservedSfuSctpChannel.d.ts.map +1 -1
  124. package/lib/samples/ObservedSfuSctpChannel.js +1 -5
  125. package/lib/samples/ObservedSfuTransport.d.ts.map +1 -1
  126. package/lib/samples/ObservedSfuTransport.js +1 -8
  127. package/lib/samples/ObservedSfus.d.ts.map +1 -1
  128. package/lib/sinks/ObserverSink.d.ts.map +1 -1
  129. package/lib/sinks/ObserverSink.js +42 -31
  130. package/lib/sinks/callEventReports.js +1 -0
  131. package/lib/sources/ObservedCallSource.d.ts +6 -3
  132. package/lib/sources/ObservedCallSource.d.ts.map +1 -1
  133. package/lib/sources/ObservedClientSource.d.ts +3 -2
  134. package/lib/sources/ObservedClientSource.d.ts.map +1 -1
  135. package/lib/sources/ObservedSfuSource.d.ts +3 -2
  136. package/lib/sources/ObservedSfuSource.d.ts.map +1 -1
  137. package/lib/sources/Sources.d.ts +8 -4
  138. package/lib/sources/Sources.d.ts.map +1 -1
  139. package/lib/sources/Sources.js +83 -46
  140. package/lib/storages/ObserverStorage.d.ts.map +1 -1
  141. package/lib/storages/SimpleStorage.d.ts.map +1 -1
  142. package/lib/storages/SimpleStorage.js +40 -23
  143. package/package.json +1 -1
  144. package/src/Evaluator.ts +17 -9
  145. package/src/Observer.ts +230 -170
  146. package/src/common/Semaphore.ts +2 -0
  147. package/src/common/callMetaReports.ts +30 -28
  148. package/src/common/logger.ts +140 -132
  149. package/src/common/types.ts +1 -1
  150. package/src/common/utils.ts +12 -1
  151. package/src/entries/CallEntry.ts +62 -0
  152. package/src/entries/ClientEntry.ts +90 -0
  153. package/src/entries/InboundTrackEntry.ts +74 -0
  154. package/src/entries/OutboundTrackEntry.ts +72 -0
  155. package/src/entries/PeerConnectionEntry.ts +133 -0
  156. package/src/entries/SfuEntry.ts +62 -0
  157. package/src/entries/SfuInboundRtpPadEntry.ts +46 -0
  158. package/src/entries/SfuOutboundRtpPadEntry.ts +44 -0
  159. package/src/entries/SfuSctpChannelEntry.ts +39 -0
  160. package/src/entries/SfuTransportEntry.ts +109 -0
  161. package/src/index.ts +11 -0
  162. package/src/middlewares/CallOperationsContext.ts +9 -5
  163. package/src/middlewares/CallProcessor.ts +4 -2
  164. package/src/middlewares/CommitTransactionMiddleware.ts +8 -5
  165. package/src/middlewares/DeleteOutdatedCallEntries.ts +24 -16
  166. package/src/middlewares/DeleteOutdatedSfuEntries.ts +24 -15
  167. package/src/middlewares/Middleware.ts +1 -0
  168. package/src/middlewares/Processor.ts +10 -5
  169. package/src/middlewares/TransactionContext.ts +1 -2
  170. package/src/middlewares/VisitObservedCallsMiddleware.ts +5 -2
  171. package/src/middlewares/VisitObservedSfusMiddleware.ts +8 -7
  172. package/src/middlewares/visitors/visitClient.ts +15 -1
  173. package/src/middlewares/visitors/visitInboundAudioTrack.ts +4 -1
  174. package/src/middlewares/visitors/visitInboundVideoTrack.ts +5 -1
  175. package/src/middlewares/visitors/visitOutboundAudioTrack.ts +5 -1
  176. package/src/middlewares/visitors/visitOutboundVideoTarck.ts +5 -1
  177. package/src/middlewares/visitors/visitPeerConnection.ts +15 -2
  178. package/src/middlewares/visitors/visitSfu.ts +7 -1
  179. package/src/middlewares/visitors/visitSfuInboundRtpPad.ts +4 -2
  180. package/src/middlewares/visitors/visitSfuOutboundRtpPad.ts +3 -1
  181. package/src/middlewares/visitors/visitSfuSctpChannel.ts +23 -21
  182. package/src/middlewares/visitors/visitSfuTransport.ts +3 -1
  183. package/src/processes/closePeerConnectionProcess.ts +3 -0
  184. package/src/processes/detachClientProcess.ts +13 -4
  185. package/src/processes/findRemoteMatches.ts +32 -21
  186. package/src/processes/inboundTrackRemoved.ts +2 -0
  187. package/src/processes/joinClientProcess.ts +8 -2
  188. package/src/processes/outboundTrackRemoved.ts +2 -0
  189. package/src/samples/ObservedCall.ts +6 -0
  190. package/src/samples/ObservedCalls.ts +13 -7
  191. package/src/samples/ObservedClient.ts +24 -8
  192. package/src/samples/ObservedInboundAudioTrack.ts +3 -2
  193. package/src/samples/ObservedInboundVideoTrack.ts +3 -2
  194. package/src/samples/ObservedOutboundAudioTrack.ts +3 -2
  195. package/src/samples/ObservedOutboundVideoTrack.ts +3 -2
  196. package/src/samples/ObservedPeerConnection.ts +27 -11
  197. package/src/samples/ObservedSfu.ts +17 -10
  198. package/src/samples/ObservedSfuInboundRtpPad.ts +5 -4
  199. package/src/samples/ObservedSfuOutboundRtpPad.ts +5 -4
  200. package/src/samples/ObservedSfuSctpChannel.ts +13 -13
  201. package/src/samples/ObservedSfuTransport.ts +19 -7
  202. package/src/samples/ObservedSfus.ts +10 -5
  203. package/src/sinks/ObserverSink.ts +51 -44
  204. package/src/sinks/callEventReports.ts +1 -1
  205. package/src/sources/ObservedCallSource.ts +9 -6
  206. package/src/sources/ObservedClientSource.ts +3 -2
  207. package/src/sources/ObservedSfuSource.ts +4 -8
  208. package/src/sources/Sources.ts +107 -22
  209. package/src/storages/ObserverStorage.ts +1 -0
  210. package/src/storages/SimpleStorage.ts +44 -21
  211. package/tsconfig.json +7 -5
  212. package/.eslintrc.js +0 -27
@@ -27,14 +27,14 @@ export class ObservedClientBuilder {
27
27
  private _clientSamples: ClientSample[] = [];
28
28
  public constructor(
29
29
  private _config: Omit<
30
- ObservedClient,
31
- | keyof IterableIterator<ObservedPeerConnection>
32
- | 'samples'
33
- | 'call'
34
- | 'getObservedPeerConnection'
35
- | 'observedPeerConnections'
36
- | 'minTimestamp'
37
- | 'maxTimestamp'
30
+ ObservedClient,
31
+ | keyof IterableIterator<ObservedPeerConnection>
32
+ | 'samples'
33
+ | 'call'
34
+ | 'getObservedPeerConnection'
35
+ | 'observedPeerConnections'
36
+ | 'minTimestamp'
37
+ | 'maxTimestamp'
38
38
  >
39
39
  ) {}
40
40
 
@@ -44,6 +44,7 @@ export class ObservedClientBuilder {
44
44
  if (clientSample.pcTransports) {
45
45
  for (const pcTransport of clientSample.pcTransports) {
46
46
  const builder = this._getOrCreatePcBuilder(pcTransport.peerConnectionId);
47
+
47
48
  builder.addTransportSample(pcTransport);
48
49
  if (pcTransport.label) {
49
50
  builder.peerConnectionLabel = pcTransport.label;
@@ -56,6 +57,7 @@ export class ObservedClientBuilder {
56
57
  continue;
57
58
  }
58
59
  const builder = this._getOrCreatePcBuilder(iceLocalCandidate.peerConnectionId);
60
+
59
61
  builder.addIceLocalCandidate(iceLocalCandidate);
60
62
  }
61
63
  }
@@ -65,21 +67,25 @@ export class ObservedClientBuilder {
65
67
  continue;
66
68
  }
67
69
  const builder = this._getOrCreatePcBuilder(iceRemoteCandidate.peerConnectionId);
70
+
68
71
  builder.addIceRemoveCandidate(iceRemoteCandidate);
69
72
  }
70
73
  }
71
74
  if (clientSample.iceCandidatePairs) {
72
75
  for (const iceCandidatePair of clientSample.iceCandidatePairs) {
73
76
  const builder = this._getOrCreatePcBuilder(iceCandidatePair.peerConnectionId);
77
+
74
78
  builder.addIceCandidatePair(iceCandidatePair);
75
79
  }
76
80
  }
77
81
  if (clientSample.inboundAudioTracks) {
78
82
  for (const trackSample of clientSample.inboundAudioTracks) {
79
83
  const { trackId, peerConnectionId } = trackSample;
84
+
80
85
  if (!trackId || !peerConnectionId) continue;
81
86
 
82
87
  const builder = this._getOrCreatePcBuilder(peerConnectionId);
88
+
83
89
  builder.addInboundAudioTrack(trackSample);
84
90
  }
85
91
  }
@@ -87,9 +93,11 @@ export class ObservedClientBuilder {
87
93
  if (clientSample.inboundVideoTracks) {
88
94
  for (const trackSample of clientSample.inboundVideoTracks) {
89
95
  const { trackId, peerConnectionId } = trackSample;
96
+
90
97
  if (!trackId || !peerConnectionId) continue;
91
98
 
92
99
  const builder = this._getOrCreatePcBuilder(peerConnectionId);
100
+
93
101
  builder.addInboundVideoTrack(trackSample);
94
102
  }
95
103
  }
@@ -97,9 +105,11 @@ export class ObservedClientBuilder {
97
105
  if (clientSample.outboundAudioTracks) {
98
106
  for (const trackSample of clientSample.outboundAudioTracks) {
99
107
  const { trackId, peerConnectionId } = trackSample;
108
+
100
109
  if (!trackId || !peerConnectionId) continue;
101
110
 
102
111
  const builder = this._getOrCreatePcBuilder(peerConnectionId);
112
+
103
113
  builder.addOutboundAudioTrack(trackSample);
104
114
  }
105
115
  }
@@ -107,9 +117,11 @@ export class ObservedClientBuilder {
107
117
  if (clientSample.outboundVideoTracks) {
108
118
  for (const trackSample of clientSample.outboundVideoTracks) {
109
119
  const { trackId, peerConnectionId } = trackSample;
120
+
110
121
  if (!trackId || !peerConnectionId) continue;
111
122
 
112
123
  const builder = this._getOrCreatePcBuilder(peerConnectionId);
124
+
113
125
  builder.addOutboundVideoTrack(trackSample);
114
126
  }
115
127
  }
@@ -125,12 +137,14 @@ export class ObservedClientBuilder {
125
137
 
126
138
  private _getOrCreatePcBuilder(peerConnectionId: string): ObservedPeerConnectionBuilder {
127
139
  let result = this._peerConnections.get(peerConnectionId);
140
+
128
141
  if (!result) {
129
142
  result = new ObservedPeerConnectionBuilder({
130
143
  peerConnectionId,
131
144
  });
132
145
  this._peerConnections.set(peerConnectionId, result);
133
146
  }
147
+
134
148
  return result;
135
149
  }
136
150
 
@@ -149,8 +163,10 @@ export class ObservedClientBuilder {
149
163
 
150
164
  for (const builder of this._peerConnections.values()) {
151
165
  const observedPeerConnection = builder.build(result);
166
+
152
167
  observedPeerConnections.set(observedPeerConnection.peerConnectionId, observedPeerConnection);
153
168
  }
169
+
154
170
  return result;
155
171
  }
156
172
  }
@@ -14,8 +14,8 @@ export class ObservedInboundAudioTrackBuilder {
14
14
  private _trackSamples: InboundAudioTrack[] = [];
15
15
  public constructor(
16
16
  private _config: Omit<
17
- ObservedInboundAudioTrack,
18
- keyof IterableIterator<ObservedPeerConnection> | 'peerConnection' | 'samples'
17
+ ObservedInboundAudioTrack,
18
+ keyof IterableIterator<ObservedPeerConnection> | 'peerConnection' | 'samples'
19
19
  >
20
20
  ) {}
21
21
 
@@ -29,6 +29,7 @@ export class ObservedInboundAudioTrackBuilder {
29
29
  ...this._config,
30
30
  samples: () => this._trackSamples.values(),
31
31
  };
32
+
32
33
  return result;
33
34
  }
34
35
  }
@@ -15,8 +15,8 @@ export class ObservedInboundVideoTrackBuilder {
15
15
 
16
16
  public constructor(
17
17
  private _config: Omit<
18
- ObservedInboundVideoTrack,
19
- keyof IterableIterator<ObservedPeerConnection> | 'peerConnection' | 'samples'
18
+ ObservedInboundVideoTrack,
19
+ keyof IterableIterator<ObservedPeerConnection> | 'peerConnection' | 'samples'
20
20
  >
21
21
  ) {}
22
22
 
@@ -30,6 +30,7 @@ export class ObservedInboundVideoTrackBuilder {
30
30
  ...this._config,
31
31
  samples: () => this._trackSamples.values(),
32
32
  };
33
+
33
34
  return result;
34
35
  }
35
36
  }
@@ -14,8 +14,8 @@ export class ObservedOutboundAudioTrackBuilder {
14
14
 
15
15
  public constructor(
16
16
  private _config: Omit<
17
- ObservedOutboundAudioTrack,
18
- keyof IterableIterator<ObservedPeerConnection> | 'peerConnection' | 'samples'
17
+ ObservedOutboundAudioTrack,
18
+ keyof IterableIterator<ObservedPeerConnection> | 'peerConnection' | 'samples'
19
19
  >
20
20
  ) {}
21
21
 
@@ -29,6 +29,7 @@ export class ObservedOutboundAudioTrackBuilder {
29
29
  ...this._config,
30
30
  samples: () => this._trackSamples.values(),
31
31
  };
32
+
32
33
  return result;
33
34
  }
34
35
  }
@@ -14,8 +14,8 @@ export class ObservedOutboundVideoTrackBuilder {
14
14
 
15
15
  public constructor(
16
16
  private _config: Omit<
17
- ObservedOutboundVideoTrack,
18
- keyof IterableIterator<ObservedPeerConnection> | 'peerConnection' | 'samples'
17
+ ObservedOutboundVideoTrack,
18
+ keyof IterableIterator<ObservedPeerConnection> | 'peerConnection' | 'samples'
19
19
  >
20
20
  ) {}
21
21
 
@@ -29,6 +29,7 @@ export class ObservedOutboundVideoTrackBuilder {
29
29
  ...this._config,
30
30
  samples: () => this._trackSamples.values(),
31
31
  };
32
+
32
33
  return result;
33
34
  }
34
35
  }
@@ -42,17 +42,17 @@ export class ObservedPeerConnectionBuilder {
42
42
  private _peerConnectionLabel?: string;
43
43
  public constructor(
44
44
  private _config: Omit<
45
- ObservedPeerConnection,
46
- | keyof IterableIterator<ObservedPeerConnection>
47
- | 'client'
48
- | 'inboundAudioTracks'
49
- | 'inboundVideoTracks'
50
- | 'outboundAudioTracks'
51
- | 'outboundVideoTracks'
52
- | 'transportSamples'
53
- | 'iceCandidatePairs'
54
- | 'iceRemoteCandidates'
55
- | 'iceLocalCandidates'
45
+ ObservedPeerConnection,
46
+ | keyof IterableIterator<ObservedPeerConnection>
47
+ | 'client'
48
+ | 'inboundAudioTracks'
49
+ | 'inboundVideoTracks'
50
+ | 'outboundAudioTracks'
51
+ | 'outboundVideoTracks'
52
+ | 'transportSamples'
53
+ | 'iceCandidatePairs'
54
+ | 'iceRemoteCandidates'
55
+ | 'iceLocalCandidates'
56
56
  >
57
57
  ) {}
58
58
 
@@ -71,6 +71,7 @@ export class ObservedPeerConnectionBuilder {
71
71
  inboundAudioTrackSample.sfuStreamId,
72
72
  inboundAudioTrackSample.sfuSinkId
73
73
  );
74
+
74
75
  builder.addSample(inboundAudioTrackSample);
75
76
  }
76
77
  }
@@ -87,6 +88,7 @@ export class ObservedPeerConnectionBuilder {
87
88
 
88
89
  private _getInboundAudioTrackBuilder(trackId: string, sfuStreamId?: string, sfuSinkId?: string): ObservedInboundAudioTrackBuilder {
89
90
  let result = this._inboundAudioTracks.get(trackId);
91
+
90
92
  if (!result) {
91
93
  result = new ObservedInboundAudioTrackBuilder({
92
94
  trackId,
@@ -95,6 +97,7 @@ export class ObservedPeerConnectionBuilder {
95
97
  });
96
98
  this._inboundAudioTracks.set(trackId, result);
97
99
  }
100
+
98
101
  return result;
99
102
  }
100
103
 
@@ -104,12 +107,14 @@ export class ObservedPeerConnectionBuilder {
104
107
  outboundAudioTrackSample.trackId,
105
108
  outboundAudioTrackSample.sfuStreamId,
106
109
  );
110
+
107
111
  builder.addSample(outboundAudioTrackSample);
108
112
  }
109
113
  }
110
114
 
111
115
  private _getOutboundAudioTrackBuilder(trackId: string, sfuStreamId?: string): ObservedOutboundAudioTrackBuilder {
112
116
  let result = this._outboundAudioTracks.get(trackId);
117
+
113
118
  if (!result) {
114
119
  result = new ObservedOutboundAudioTrackBuilder({
115
120
  trackId,
@@ -117,6 +122,7 @@ export class ObservedPeerConnectionBuilder {
117
122
  });
118
123
  this._outboundAudioTracks.set(trackId, result);
119
124
  }
125
+
120
126
  return result;
121
127
  }
122
128
 
@@ -127,12 +133,14 @@ export class ObservedPeerConnectionBuilder {
127
133
  inboundVideoTrackSample.sfuStreamId,
128
134
  inboundVideoTrackSample.sfuSinkId,
129
135
  );
136
+
130
137
  builder.addSample(inboundVideoTrackSample);
131
138
  }
132
139
  }
133
140
 
134
141
  private _getInboundVideoTrackBuilder(trackId: string, sfuStreamId?: string, sfuSinkId?: string): ObservedInboundVideoTrackBuilder {
135
142
  let result = this._inboundVideoTracks.get(trackId);
143
+
136
144
  if (!result) {
137
145
  result = new ObservedInboundVideoTrackBuilder({
138
146
  trackId,
@@ -141,6 +149,7 @@ export class ObservedPeerConnectionBuilder {
141
149
  });
142
150
  this._inboundVideoTracks.set(trackId, result);
143
151
  }
152
+
144
153
  return result;
145
154
  }
146
155
 
@@ -150,12 +159,14 @@ export class ObservedPeerConnectionBuilder {
150
159
  outboundVideoTrackSample.trackId,
151
160
  outboundVideoTrackSample.sfuStreamId,
152
161
  );
162
+
153
163
  builder.addSample(outboundVideoTrackSample);
154
164
  }
155
165
  }
156
166
 
157
167
  private _getOutboundVideoTrackBuilder(trackId: string, sfuStreamId?: string): ObservedOutboundVideoTrackBuilder {
158
168
  let result = this._outboundVideoTracks.get(trackId);
169
+
159
170
  if (!result) {
160
171
  result = new ObservedOutboundVideoTrackBuilder({
161
172
  trackId,
@@ -163,6 +174,7 @@ export class ObservedPeerConnectionBuilder {
163
174
  });
164
175
  this._outboundVideoTracks.set(trackId, result);
165
176
  }
177
+
166
178
  return result;
167
179
  }
168
180
 
@@ -188,21 +200,25 @@ export class ObservedPeerConnectionBuilder {
188
200
 
189
201
  for (const builder of this._inboundAudioTracks.values()) {
190
202
  const observedInboundAudioTrack = builder.build(result);
203
+
191
204
  inboundAudioTracks.set(observedInboundAudioTrack.trackId, observedInboundAudioTrack);
192
205
  }
193
206
 
194
207
  for (const builder of this._outboundAudioTracks.values()) {
195
208
  const observedOutboundAudioTrack = builder.build(result);
209
+
196
210
  outboundAudioTracks.set(observedOutboundAudioTrack.trackId, observedOutboundAudioTrack);
197
211
  }
198
212
 
199
213
  for (const builder of this._inboundVideoTracks.values()) {
200
214
  const observedInboundVideoTrack = builder.build(result);
215
+
201
216
  inboundVideoTracks.set(observedInboundVideoTrack.trackId, observedInboundVideoTrack);
202
217
  }
203
218
 
204
219
  for (const builder of this._outboundVideoTracks.values()) {
205
220
  const observedOutboundVideoTrack = builder.build(result);
221
+
206
222
  outboundVideoTracks.set(observedOutboundVideoTrack.trackId, observedOutboundVideoTrack);
207
223
  }
208
224
 
@@ -1,6 +1,5 @@
1
- import { ClientSample, SfuSample } from '@observertc/sample-schemas-js';
2
- import { ObservedPeerConnection, ObservedPeerConnectionBuilder } from './ObservedPeerConnection';
3
- import { ObservedCall } from './ObservedCall';
1
+ import { SfuSample } from '@observertc/sample-schemas-js';
2
+ import { ObservedPeerConnection } from './ObservedPeerConnection';
4
3
  import { ObservedSfuTransport, ObservedSfuTransportBuilder } from './ObservedSfuTransport';
5
4
 
6
5
  export interface ObservedSfu {
@@ -26,13 +25,13 @@ export class ObservedSfuBuilder {
26
25
  private _sfuSamples: SfuSample[] = [];
27
26
  public constructor(
28
27
  private _config: Omit<
29
- ObservedSfu,
30
- | keyof IterableIterator<ObservedPeerConnection>
31
- | 'samples'
32
- | 'observedSfuTransports'
33
- | 'getObservedSfuTransport'
34
- | 'minTimestamp'
35
- | 'maxTimestamp'
28
+ ObservedSfu,
29
+ | keyof IterableIterator<ObservedPeerConnection>
30
+ | 'samples'
31
+ | 'observedSfuTransports'
32
+ | 'getObservedSfuTransport'
33
+ | 'minTimestamp'
34
+ | 'maxTimestamp'
36
35
  >
37
36
  ) {}
38
37
 
@@ -42,6 +41,7 @@ export class ObservedSfuBuilder {
42
41
  if (sfuSample.transports) {
43
42
  for (const sfuTransport of sfuSample.transports) {
44
43
  const builder = this._getOrCreateSfuTransportBuilder(sfuTransport.transportId);
44
+
45
45
  builder.addTransportSample(sfuTransport);
46
46
  }
47
47
  }
@@ -49,6 +49,7 @@ export class ObservedSfuBuilder {
49
49
  if (sfuSample.inboundRtpPads) {
50
50
  for (const inboundRtpPad of sfuSample.inboundRtpPads) {
51
51
  const builder = this._getOrCreateSfuTransportBuilder(inboundRtpPad.transportId);
52
+
52
53
  builder.addSfuInboundRtpPad(inboundRtpPad);
53
54
  }
54
55
  }
@@ -56,6 +57,7 @@ export class ObservedSfuBuilder {
56
57
  if (sfuSample.outboundRtpPads) {
57
58
  for (const outboundRtpPad of sfuSample.outboundRtpPads) {
58
59
  const builder = this._getOrCreateSfuTransportBuilder(outboundRtpPad.transportId);
60
+
59
61
  builder.addSfuOutboundRtpPad(outboundRtpPad);
60
62
  }
61
63
  }
@@ -63,6 +65,7 @@ export class ObservedSfuBuilder {
63
65
  if (sfuSample.sctpChannels) {
64
66
  for (const sctpChannel of sfuSample.sctpChannels) {
65
67
  const builder = this._getOrCreateSfuTransportBuilder(sctpChannel.transportId);
68
+
66
69
  builder.addSfuSctpChannel(sctpChannel);
67
70
  }
68
71
  }
@@ -78,12 +81,14 @@ export class ObservedSfuBuilder {
78
81
 
79
82
  private _getOrCreateSfuTransportBuilder(transportId: string): ObservedSfuTransportBuilder {
80
83
  let result = this._sfuTransports.get(transportId);
84
+
81
85
  if (!result) {
82
86
  result = new ObservedSfuTransportBuilder({
83
87
  transportId,
84
88
  });
85
89
  this._sfuTransports.set(transportId, result);
86
90
  }
91
+
87
92
  return result;
88
93
  }
89
94
 
@@ -101,8 +106,10 @@ export class ObservedSfuBuilder {
101
106
 
102
107
  for (const builder of this._sfuTransports.values()) {
103
108
  const observedSfuTransport = builder.build(result);
109
+
104
110
  observedSfuTransports.set(observedSfuTransport.transportId, observedSfuTransport);
105
111
  }
112
+
106
113
  return result;
107
114
  }
108
115
  }
@@ -12,10 +12,10 @@ export class ObservedSfuInboundRtpPadBuilder {
12
12
  private _samples: SfuInboundRtpPad[] = [];
13
13
  public constructor(
14
14
  private _config: Omit<
15
- ObservedSfuInboundRtpPad,
16
- | keyof IterableIterator<SfuInboundRtpPad>
17
- | 'sfuTransport'
18
- | 'samples'
15
+ ObservedSfuInboundRtpPad,
16
+ | keyof IterableIterator<SfuInboundRtpPad>
17
+ | 'sfuTransport'
18
+ | 'samples'
19
19
  >
20
20
  ) {}
21
21
 
@@ -29,6 +29,7 @@ export class ObservedSfuInboundRtpPadBuilder {
29
29
  ...this._config,
30
30
  samples: () => this._samples.values(),
31
31
  };
32
+
32
33
  return result;
33
34
  }
34
35
  }
@@ -12,10 +12,10 @@ export class ObservedSfuOutboundRtpPadBuilder {
12
12
  private _samples: SfuOutboundRtpPad[] = [];
13
13
  public constructor(
14
14
  private _config: Omit<
15
- ObservedSfuOutboundRtpPad,
16
- | keyof IterableIterator<SfuOutboundRtpPad>
17
- | 'sfuTransport'
18
- | 'samples'
15
+ ObservedSfuOutboundRtpPad,
16
+ | keyof IterableIterator<SfuOutboundRtpPad>
17
+ | 'sfuTransport'
18
+ | 'samples'
19
19
  >
20
20
  ) {}
21
21
 
@@ -29,6 +29,7 @@ export class ObservedSfuOutboundRtpPadBuilder {
29
29
  ...this._config,
30
30
  samples: () => this._samples.values(),
31
31
  };
32
+
32
33
  return result;
33
34
  }
34
35
  }
@@ -6,30 +6,30 @@ export interface ObservedSfuSctpChannel {
6
6
  readonly channelId: string;
7
7
 
8
8
  samples(): IterableIterator<SfuSctpChannel>;
9
- }
9
+ }
10
10
 
11
- export class ObservedSfuSctpChannelBuilder {
11
+ export class ObservedSfuSctpChannelBuilder {
12
12
  private _samples: SfuSctpChannel[] = [];
13
13
  public constructor(
14
- private _config: Omit<
14
+ private _config: Omit<
15
15
  ObservedSfuSctpChannel,
16
16
  | keyof IterableIterator<SfuSctpChannel>
17
17
  | 'sfuTransport'
18
18
  | 'samples'
19
- >
19
+ >
20
20
  ) {}
21
21
 
22
22
  public addSample(sfuSctpChannel: SfuSctpChannel) {
23
- this._samples.push(sfuSctpChannel);
23
+ this._samples.push(sfuSctpChannel);
24
24
  }
25
25
 
26
26
  public build(sfuTransport: ObservedSfuTransport): ObservedSfuSctpChannel {
27
- const result: ObservedSfuSctpChannel = {
28
- sfuTransport,
29
- ...this._config,
30
- samples: () => this._samples.values(),
31
- };
32
- return result;
27
+ const result: ObservedSfuSctpChannel = {
28
+ sfuTransport,
29
+ ...this._config,
30
+ samples: () => this._samples.values(),
31
+ };
32
+
33
+ return result;
33
34
  }
34
- }
35
-
35
+ }
@@ -27,13 +27,13 @@ export class ObservedSfuTransportBuilder {
27
27
  private _transportSamples: SfuTransport[] = [];
28
28
  public constructor(
29
29
  private _config: Omit<
30
- ObservedSfuTransport,
31
- | keyof IterableIterator<ObservedSfuTransport>
32
- | 'sfu'
33
- | 'inboundRtpPads'
34
- | 'outboundRtpPads'
35
- | 'sfuSctpChannels'
36
- | 'transportSamples'
30
+ ObservedSfuTransport,
31
+ | keyof IterableIterator<ObservedSfuTransport>
32
+ | 'sfu'
33
+ | 'inboundRtpPads'
34
+ | 'outboundRtpPads'
35
+ | 'sfuSctpChannels'
36
+ | 'transportSamples'
37
37
  >
38
38
  ) {}
39
39
 
@@ -44,54 +44,63 @@ export class ObservedSfuTransportBuilder {
44
44
  public addSfuInboundRtpPad(inboundRtpPad: SfuInboundRtpPad) {
45
45
  if (inboundRtpPad.padId) {
46
46
  const builder = this._getSfuInboundRtpPadBuilder(inboundRtpPad.padId);
47
+
47
48
  builder.addSample(inboundRtpPad);
48
49
  }
49
50
  }
50
51
 
51
52
  private _getSfuInboundRtpPadBuilder(padId: string): ObservedSfuInboundRtpPadBuilder {
52
53
  let result = this._inboundRtpPads.get(padId);
54
+
53
55
  if (!result) {
54
56
  result = new ObservedSfuInboundRtpPadBuilder({
55
57
  padId,
56
58
  });
57
59
  this._inboundRtpPads.set(padId, result);
58
60
  }
61
+
59
62
  return result;
60
63
  }
61
64
 
62
65
  public addSfuOutboundRtpPad(outboundRtpPad: SfuOutboundRtpPad) {
63
66
  if (outboundRtpPad.padId) {
64
67
  const builder = this._getSfuOutboundRtpPadBuilder(outboundRtpPad.padId);
68
+
65
69
  builder.addSample(outboundRtpPad);
66
70
  }
67
71
  }
68
72
 
69
73
  private _getSfuOutboundRtpPadBuilder(padId: string): ObservedSfuOutboundRtpPadBuilder {
70
74
  let result = this._outboundRtpPads.get(padId);
75
+
71
76
  if (!result) {
72
77
  result = new ObservedSfuOutboundRtpPadBuilder({
73
78
  padId,
74
79
  });
75
80
  this._outboundRtpPads.set(padId, result);
76
81
  }
82
+
77
83
  return result;
78
84
  }
79
85
 
80
86
  public addSfuSctpChannel(sfuSctpChannel: SfuSctpChannel) {
81
87
  if (sfuSctpChannel.channelId) {
82
88
  const builder = this._getSfuSctpChannel(sfuSctpChannel.channelId);
89
+
83
90
  builder.addSample(sfuSctpChannel);
84
91
  }
85
92
  }
86
93
 
87
94
  private _getSfuSctpChannel(channelId: string): ObservedSfuSctpChannelBuilder {
88
95
  let result = this._sctpChannels.get(channelId);
96
+
89
97
  if (!result) {
90
98
  result = new ObservedSfuSctpChannelBuilder({
91
99
  channelId,
92
100
  });
93
101
  this._sctpChannels.set(channelId, result);
94
102
  }
103
+
95
104
  return result;
96
105
  }
97
106
 
@@ -112,16 +121,19 @@ export class ObservedSfuTransportBuilder {
112
121
 
113
122
  for (const builder of this._inboundRtpPads.values()) {
114
123
  const observedInboundRtpPad = builder.build(result);
124
+
115
125
  sfuInboundRtpPads.set(observedInboundRtpPad.padId, observedInboundRtpPad);
116
126
  }
117
127
 
118
128
  for (const builder of this._outboundRtpPads.values()) {
119
129
  const observedOutboundRtpPad = builder.build(result);
130
+
120
131
  sfuOutboundRtpPads.set(observedOutboundRtpPad.padId, observedOutboundRtpPad);
121
132
  }
122
133
 
123
134
  for (const builder of this._sctpChannels.values()) {
124
135
  const observedSfuSctpChannel = builder.build(result);
136
+
125
137
  sfuSctpChannelsMap.set(observedSfuSctpChannel.channelId, observedSfuSctpChannel);
126
138
  }
127
139