@observertc/observer-js 1.0.1-ec27289.0 → 1.1.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 (210) hide show
  1. package/README.md +2184 -1
  2. package/dist/index.d.mts +6842 -0
  3. package/dist/index.d.ts +6842 -0
  4. package/dist/index.js +7736 -0
  5. package/dist/index.js.map +1 -0
  6. package/dist/index.mjs +7608 -0
  7. package/dist/index.mjs.map +1 -0
  8. package/package.json +44 -18
  9. package/.eslintrc.json +0 -143
  10. package/.prettierignore +0 -5
  11. package/.prettierrc +0 -7
  12. package/jest.config.js +0 -9
  13. package/lib/ObservedCall.d.ts +0 -83
  14. package/lib/ObservedCall.d.ts.map +0 -1
  15. package/lib/ObservedCall.js +0 -203
  16. package/lib/ObservedCallSummary.d.ts +0 -18
  17. package/lib/ObservedCallSummary.d.ts.map +0 -1
  18. package/lib/ObservedCallSummary.js +0 -2
  19. package/lib/ObservedCertificate.d.ts +0 -19
  20. package/lib/ObservedCertificate.d.ts.map +0 -1
  21. package/lib/ObservedCertificate.js +0 -38
  22. package/lib/ObservedClient.d.ts +0 -131
  23. package/lib/ObservedClient.d.ts.map +0 -1
  24. package/lib/ObservedClient.js +0 -520
  25. package/lib/ObservedClientEventMonitor.d.ts +0 -89
  26. package/lib/ObservedClientEventMonitor.d.ts.map +0 -1
  27. package/lib/ObservedClientEventMonitor.js +0 -247
  28. package/lib/ObservedClientSummary.d.ts +0 -23
  29. package/lib/ObservedClientSummary.d.ts.map +0 -1
  30. package/lib/ObservedClientSummary.js +0 -2
  31. package/lib/ObservedCodec.d.ts +0 -22
  32. package/lib/ObservedCodec.d.ts.map +0 -1
  33. package/lib/ObservedCodec.js +0 -45
  34. package/lib/ObservedDataChannel.d.ts +0 -30
  35. package/lib/ObservedDataChannel.d.ts.map +0 -1
  36. package/lib/ObservedDataChannel.js +0 -75
  37. package/lib/ObservedIceCandidate.d.ts +0 -29
  38. package/lib/ObservedIceCandidate.d.ts.map +0 -1
  39. package/lib/ObservedIceCandidate.js +0 -59
  40. package/lib/ObservedIceCandidatePair.d.ts +0 -44
  41. package/lib/ObservedIceCandidatePair.d.ts.map +0 -1
  42. package/lib/ObservedIceCandidatePair.js +0 -111
  43. package/lib/ObservedIceTransport.d.ts +0 -36
  44. package/lib/ObservedIceTransport.d.ts.map +0 -1
  45. package/lib/ObservedIceTransport.js +0 -93
  46. package/lib/ObservedInboundRtp.d.ts +0 -92
  47. package/lib/ObservedInboundRtp.d.ts.map +0 -1
  48. package/lib/ObservedInboundRtp.js +0 -193
  49. package/lib/ObservedInboundTrack.d.ts +0 -31
  50. package/lib/ObservedInboundTrack.d.ts.map +0 -1
  51. package/lib/ObservedInboundTrack.js +0 -59
  52. package/lib/ObservedMediaPlayout.d.ts +0 -22
  53. package/lib/ObservedMediaPlayout.d.ts.map +0 -1
  54. package/lib/ObservedMediaPlayout.js +0 -42
  55. package/lib/ObservedMediaSource.d.ts +0 -28
  56. package/lib/ObservedMediaSource.d.ts.map +0 -1
  57. package/lib/ObservedMediaSource.js +0 -55
  58. package/lib/ObservedOutboundRtp.d.ts +0 -62
  59. package/lib/ObservedOutboundRtp.d.ts.map +0 -1
  60. package/lib/ObservedOutboundRtp.js +0 -144
  61. package/lib/ObservedOutboundTrack.d.ts +0 -31
  62. package/lib/ObservedOutboundTrack.d.ts.map +0 -1
  63. package/lib/ObservedOutboundTrack.js +0 -59
  64. package/lib/ObservedPeerConnection.d.ts +0 -185
  65. package/lib/ObservedPeerConnection.d.ts.map +0 -1
  66. package/lib/ObservedPeerConnection.js +0 -710
  67. package/lib/ObservedPeerConnectionTransport.d.ts +0 -17
  68. package/lib/ObservedPeerConnectionTransport.d.ts.map +0 -1
  69. package/lib/ObservedPeerConnectionTransport.js +0 -34
  70. package/lib/ObservedRemoteInboundRtp.d.ts +0 -30
  71. package/lib/ObservedRemoteInboundRtp.d.ts.map +0 -1
  72. package/lib/ObservedRemoteInboundRtp.js +0 -60
  73. package/lib/ObservedRemoteOutboundRtp.d.ts +0 -30
  74. package/lib/ObservedRemoteOutboundRtp.d.ts.map +0 -1
  75. package/lib/ObservedRemoteOutboundRtp.js +0 -60
  76. package/lib/ObservedTURN.d.ts +0 -31
  77. package/lib/ObservedTURN.d.ts.map +0 -1
  78. package/lib/ObservedTURN.js +0 -58
  79. package/lib/ObservedTurnServer.d.ts +0 -25
  80. package/lib/ObservedTurnServer.d.ts.map +0 -1
  81. package/lib/ObservedTurnServer.js +0 -59
  82. package/lib/Observer.d.ts +0 -61
  83. package/lib/Observer.d.ts.map +0 -1
  84. package/lib/Observer.js +0 -156
  85. package/lib/ObserverSummary.d.ts +0 -13
  86. package/lib/ObserverSummary.d.ts.map +0 -1
  87. package/lib/ObserverSummary.js +0 -2
  88. package/lib/common/Middleware.d.ts +0 -17
  89. package/lib/common/Middleware.d.ts.map +0 -1
  90. package/lib/common/Middleware.js +0 -60
  91. package/lib/common/SingleExecutor.d.ts +0 -3
  92. package/lib/common/SingleExecutor.d.ts.map +0 -1
  93. package/lib/common/SingleExecutor.js +0 -31
  94. package/lib/common/logger.d.ts +0 -17
  95. package/lib/common/logger.d.ts.map +0 -1
  96. package/lib/common/logger.js +0 -50
  97. package/lib/common/types.d.ts +0 -3
  98. package/lib/common/types.d.ts.map +0 -1
  99. package/lib/common/types.js +0 -3
  100. package/lib/common/utils.d.ts +0 -11
  101. package/lib/common/utils.d.ts.map +0 -1
  102. package/lib/common/utils.js +0 -63
  103. package/lib/detectors/Detector.d.ts +0 -5
  104. package/lib/detectors/Detector.d.ts.map +0 -1
  105. package/lib/detectors/Detector.js +0 -3
  106. package/lib/detectors/Detectors.d.ts +0 -11
  107. package/lib/detectors/Detectors.d.ts.map +0 -1
  108. package/lib/detectors/Detectors.js +0 -34
  109. package/lib/index.d.ts +0 -27
  110. package/lib/index.d.ts.map +0 -1
  111. package/lib/index.js +0 -47
  112. package/lib/monitors/TurnUsageMonitor.d.ts +0 -1
  113. package/lib/monitors/TurnUsageMonitor.d.ts.map +0 -1
  114. package/lib/monitors/TurnUsageMonitor.js +0 -146
  115. package/lib/schema/ClientEventTypes.d.ts +0 -100
  116. package/lib/schema/ClientEventTypes.d.ts.map +0 -1
  117. package/lib/schema/ClientEventTypes.js +0 -38
  118. package/lib/schema/ClientMetaTypes.d.ts +0 -34
  119. package/lib/schema/ClientMetaTypes.d.ts.map +0 -1
  120. package/lib/schema/ClientMetaTypes.js +0 -16
  121. package/lib/schema/ClientSample.d.ts +0 -1333
  122. package/lib/schema/ClientSample.d.ts.map +0 -1
  123. package/lib/schema/ClientSample.js +0 -4
  124. package/lib/scores/CalculatedScore.d.ts +0 -6
  125. package/lib/scores/CalculatedScore.d.ts.map +0 -1
  126. package/lib/scores/CalculatedScore.js +0 -2
  127. package/lib/scores/DefaultCallScoreCalculator.d.ts +0 -7
  128. package/lib/scores/DefaultCallScoreCalculator.d.ts.map +0 -1
  129. package/lib/scores/DefaultCallScoreCalculator.js +0 -21
  130. package/lib/scores/ScoreCalculator.d.ts +0 -4
  131. package/lib/scores/ScoreCalculator.d.ts.map +0 -1
  132. package/lib/scores/ScoreCalculator.js +0 -2
  133. package/lib/updaters/CallUpdater.d.ts +0 -5
  134. package/lib/updaters/CallUpdater.d.ts.map +0 -1
  135. package/lib/updaters/CallUpdater.js +0 -2
  136. package/lib/updaters/ObserverUpdater.d.ts +0 -5
  137. package/lib/updaters/ObserverUpdater.d.ts.map +0 -1
  138. package/lib/updaters/ObserverUpdater.js +0 -2
  139. package/lib/updaters/OnAllCallObserverUpdater_.d.ts +0 -13
  140. package/lib/updaters/OnAllCallObserverUpdater_.d.ts.map +0 -1
  141. package/lib/updaters/OnAllCallObserverUpdater_.js +0 -38
  142. package/lib/updaters/OnAllClientCallUpdater.d.ts +0 -13
  143. package/lib/updaters/OnAllClientCallUpdater.d.ts.map +0 -1
  144. package/lib/updaters/OnAllClientCallUpdater.js +0 -37
  145. package/lib/updaters/OnAnyCallObserverUpdater_.d.ts +0 -11
  146. package/lib/updaters/OnAnyCallObserverUpdater_.d.ts.map +0 -1
  147. package/lib/updaters/OnAnyCallObserverUpdater_.js +0 -27
  148. package/lib/updaters/OnAnyClientCallUpdater.d.ts +0 -11
  149. package/lib/updaters/OnAnyClientCallUpdater.d.ts.map +0 -1
  150. package/lib/updaters/OnAnyClientCallUpdater.js +0 -27
  151. package/lib/updaters/OnIntervalUpdater.d.ts +0 -10
  152. package/lib/updaters/OnIntervalUpdater.d.ts.map +0 -1
  153. package/lib/updaters/OnIntervalUpdater.js +0 -17
  154. package/lib/updaters/Updater.d.ts +0 -6
  155. package/lib/updaters/Updater.d.ts.map +0 -1
  156. package/lib/updaters/Updater.js +0 -2
  157. package/lib/utils/RemoteTrackResolver.d.ts +0 -7
  158. package/lib/utils/RemoteTrackResolver.d.ts.map +0 -1
  159. package/lib/utils/RemoteTrackResolver.js +0 -2
  160. package/src/ObservedCall.ts +0 -322
  161. package/src/ObservedCallSummary.ts +0 -22
  162. package/src/ObservedCertificate.ts +0 -43
  163. package/src/ObservedClient.ts +0 -673
  164. package/src/ObservedClientEventMonitor.ts +0 -301
  165. package/src/ObservedClientSummary.ts +0 -24
  166. package/src/ObservedCodec.ts +0 -49
  167. package/src/ObservedDataChannel.ts +0 -85
  168. package/src/ObservedIceCandidate.ts +0 -64
  169. package/src/ObservedIceCandidatePair.ts +0 -118
  170. package/src/ObservedIceTransport.ts +0 -99
  171. package/src/ObservedInboundRtp.ts +0 -205
  172. package/src/ObservedInboundTrack.ts +0 -73
  173. package/src/ObservedMediaPlayout.ts +0 -49
  174. package/src/ObservedMediaSource.ts +0 -60
  175. package/src/ObservedOutboundRtp.ts +0 -156
  176. package/src/ObservedOutboundTrack.ts +0 -72
  177. package/src/ObservedPeerConnection.ts +0 -1019
  178. package/src/ObservedPeerConnectionTransport.ts +0 -38
  179. package/src/ObservedRemoteInboundRtp.ts +0 -64
  180. package/src/ObservedRemoteOutboundRtp.ts +0 -65
  181. package/src/ObservedTURN.ts +0 -86
  182. package/src/ObservedTurnServer.ts +0 -72
  183. package/src/Observer.ts +0 -239
  184. package/src/ObserverSummary.ts +0 -15
  185. package/src/common/Middleware.ts +0 -84
  186. package/src/common/SingleExecutor.ts +0 -36
  187. package/src/common/logger.ts +0 -82
  188. package/src/common/types.ts +0 -4
  189. package/src/common/utils.ts +0 -69
  190. package/src/detectors/Detector.ts +0 -6
  191. package/src/detectors/Detectors.ts +0 -38
  192. package/src/index.ts +0 -28
  193. package/src/monitors/TurnUsageMonitor.ts +0 -187
  194. package/src/schema/ClientEventTypes.ts +0 -112
  195. package/src/schema/ClientMetaTypes.ts +0 -41
  196. package/src/schema/ClientSample.ts +0 -1682
  197. package/src/scores/CalculatedScore.ts +0 -6
  198. package/src/scores/DefaultCallScoreCalculator.ts +0 -23
  199. package/src/scores/ScoreCalculator.ts +0 -3
  200. package/src/updaters/CallUpdater.ts +0 -5
  201. package/src/updaters/ObserverUpdater.ts +0 -5
  202. package/src/updaters/OnAllCallObserverUpdater_.ts +0 -46
  203. package/src/updaters/OnAllClientCallUpdater.ts +0 -46
  204. package/src/updaters/OnAnyCallObserverUpdater_.ts +0 -32
  205. package/src/updaters/OnAnyClientCallUpdater.ts +0 -32
  206. package/src/updaters/OnIntervalUpdater.ts +0 -19
  207. package/src/updaters/Updater.ts +0 -5
  208. package/src/utils/RemoteTrackResolver.ts +0 -12
  209. package/tsconfig.json +0 -19
  210. package/tslint.json +0 -6
@@ -1,710 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ObservedPeerConnection = void 0;
4
- const events_1 = require("events");
5
- const ObservedInboundRtp_1 = require("./ObservedInboundRtp");
6
- const logger_1 = require("./common/logger");
7
- const ObservedOutboundRtp_1 = require("./ObservedOutboundRtp");
8
- const ObservedCertificate_1 = require("./ObservedCertificate");
9
- const ObservedCodec_1 = require("./ObservedCodec");
10
- const ObservedDataChannel_1 = require("./ObservedDataChannel");
11
- const ObservedIceCandidate_1 = require("./ObservedIceCandidate");
12
- const ObservedIceCandidatePair_1 = require("./ObservedIceCandidatePair");
13
- const ObservedIceTransport_1 = require("./ObservedIceTransport");
14
- const ObservedMediaSource_1 = require("./ObservedMediaSource");
15
- const ObservedPeerConnectionTransport_1 = require("./ObservedPeerConnectionTransport");
16
- const ObservedMediaPlayout_1 = require("./ObservedMediaPlayout");
17
- const ObservedRemoteInboundRtp_1 = require("./ObservedRemoteInboundRtp");
18
- const ObservedRemoteOutboundRtp_1 = require("./ObservedRemoteOutboundRtp");
19
- const ObservedInboundTrack_1 = require("./ObservedInboundTrack");
20
- const ObservedOutboundTrack_1 = require("./ObservedOutboundTrack");
21
- const utils_1 = require("./common/utils");
22
- const logger = (0, logger_1.createLogger)('ObservedPeerConnection');
23
- class ObservedPeerConnection extends events_1.EventEmitter {
24
- peerConnectionId;
25
- client;
26
- _visited = true;
27
- appData;
28
- calculatedScore = {
29
- weight: 1,
30
- value: undefined,
31
- };
32
- closed = false;
33
- // timestamp of the PEER_CONNECTION_OPENED event
34
- openedAt;
35
- // timestamp of the PEER_CONNECTION_CLOSED event
36
- closedAt;
37
- updated = Date.now();
38
- availableIncomingBitrate = 0;
39
- availableOutgoingBitrate = 0;
40
- totalInboundPacketsLost = 0;
41
- totalInboundPacketsReceived = 0;
42
- totalOutboundPacketsSent = 0;
43
- totalDataChannelBytesSent = 0;
44
- totalDataChannelBytesReceived = 0;
45
- totalDataChannelMessagesSent = 0;
46
- totalDataChannelMessagesReceived = 0;
47
- totalSentAudioBytes = 0;
48
- totalSentVideoBytes = 0;
49
- totalSentAudioPackets = 0;
50
- totalSentVideoPackets = 0;
51
- totalReceivedAudioPacktes = 0;
52
- totalReceivedVideoPackets = 0;
53
- totalReceivedAudioBytes = 0;
54
- totalReceivedVideoBytes = 0;
55
- deltaInboundPacketsLost = 0;
56
- deltaInboundPacketsReceived = 0;
57
- deltaOutboundPacketsSent = 0;
58
- deltaDataChannelBytesSent = 0;
59
- deltaDataChannelBytesReceived = 0;
60
- deltaDataChannelMessagesSent = 0;
61
- deltaDataChannelMessagesReceived = 0;
62
- deltaInboundReceivedBytes = 0;
63
- deltaOutboundSentBytes = 0;
64
- deltaReceivedAudioBytes = 0;
65
- deltaReceivedVideoBytes = 0;
66
- deltaReceivedAudioPackets = 0;
67
- deltaReceivedVideoPackets = 0;
68
- deltaSentAudioBytes = 0;
69
- deltaSentVideoBytes = 0;
70
- deltaTransportSentBytes = 0;
71
- deltaTransportReceivedBytes = 0;
72
- receivingPacketsPerSecond = 0;
73
- sendingPacketsPerSecond = 0;
74
- sendingAudioBitrate = 0;
75
- sendingVideoBitrate = 0;
76
- receivingAudioBitrate = 0;
77
- receivingVideoBitrate = 0;
78
- currentRttInMs;
79
- currentJitter;
80
- usingTCP = false;
81
- usingTURN = false;
82
- observedTurnServer;
83
- observedCertificates = new Map();
84
- observedCodecs = new Map();
85
- observedDataChannels = new Map();
86
- observedIceCandidates = new Map();
87
- observedIceCandidatesPair = new Map();
88
- observedIceTransports = new Map();
89
- observedInboundRtps = new Map();
90
- observedInboundTracks = new Map();
91
- observedMediaPlayouts = new Map();
92
- observedMediaSources = new Map();
93
- observedOutboundRtps = new Map();
94
- observedOutboundTracks = new Map();
95
- observedPeerConnectionTransports = new Map();
96
- observedRemoteInboundRtps = new Map();
97
- observedRemoteOutboundRtps = new Map();
98
- constructor(peerConnectionId, client) {
99
- super();
100
- this.peerConnectionId = peerConnectionId;
101
- this.client = client;
102
- this.setMaxListeners(Infinity);
103
- }
104
- get score() {
105
- return this.calculatedScore.value;
106
- }
107
- get visited() {
108
- const visited = this._visited;
109
- this._visited = false;
110
- return visited;
111
- }
112
- get codecs() {
113
- return [...this.observedCodecs.values()];
114
- }
115
- get inboundRtps() {
116
- return [...this.observedInboundRtps.values()];
117
- }
118
- get remoteOutboundRtps() {
119
- return [...this.observedRemoteOutboundRtps.values()];
120
- }
121
- get outboundRtps() {
122
- return [...this.observedOutboundRtps.values()];
123
- }
124
- get remoteInboundRtps() {
125
- return [...this.observedRemoteInboundRtps.values()];
126
- }
127
- get mediaSources() {
128
- return [...this.observedMediaSources.values()];
129
- }
130
- get mediaPlayouts() {
131
- return [...this.observedMediaPlayouts.values()];
132
- }
133
- get dataChannels() {
134
- return [...this.observedDataChannels.values()];
135
- }
136
- get peerConnectionTransports() {
137
- return [...this.observedPeerConnectionTransports.values()];
138
- }
139
- get iceTransports() {
140
- return [...this.observedIceTransports.values()];
141
- }
142
- get iceCandidates() {
143
- return [...this.observedIceCandidates.values()];
144
- }
145
- get iceCandidatePairs() {
146
- return [...this.observedIceCandidatesPair.values()];
147
- }
148
- get certificates() {
149
- return [...this.observedCertificates.values()];
150
- }
151
- get selectedIceCandidatePairs() {
152
- return this.iceTransports.map((iceTransport) => iceTransport.getSelectedCandidatePair())
153
- .filter((pair) => pair !== undefined);
154
- }
155
- get selectedIceCandiadtePairForTurn() {
156
- return this.selectedIceCandidatePairs
157
- .filter((pair) => pair.getLocalCandidate()?.candidateType === 'relay' &&
158
- pair.getRemoteCandidate()?.url?.startsWith('turn:'));
159
- }
160
- close() {
161
- if (this.closed)
162
- return;
163
- this.closed = true;
164
- this.observedCertificates.clear();
165
- this.observedCodecs.clear();
166
- this.observedDataChannels.clear();
167
- this.observedIceCandidates.clear();
168
- this.observedIceCandidatesPair.clear();
169
- this.observedIceTransports.clear();
170
- this.observedInboundRtps.clear();
171
- this.observedInboundTracks.clear();
172
- this.observedMediaPlayouts.clear();
173
- this.observedMediaSources.clear();
174
- this.observedOutboundRtps.clear();
175
- this.observedOutboundTracks.clear();
176
- this.observedPeerConnectionTransports.clear();
177
- this.observedRemoteInboundRtps.clear();
178
- this.observedRemoteOutboundRtps.clear();
179
- this.client.call.observer.observedTURN.removePeerConnection(this);
180
- if (!this.closedAt)
181
- this.closedAt = Date.now();
182
- this.emit('close');
183
- }
184
- accept(sample) {
185
- if (this.closed)
186
- return;
187
- this._visited = true;
188
- this.availableIncomingBitrate = 0;
189
- this.availableOutgoingBitrate = 0;
190
- this.deltaInboundPacketsLost = 0;
191
- this.deltaInboundPacketsReceived = 0;
192
- this.deltaOutboundPacketsSent = 0;
193
- this.deltaDataChannelBytesSent = 0;
194
- this.deltaDataChannelBytesReceived = 0;
195
- this.deltaInboundReceivedBytes = 0;
196
- this.deltaOutboundSentBytes = 0;
197
- this.deltaReceivedAudioBytes = 0;
198
- this.deltaReceivedVideoBytes = 0;
199
- this.deltaReceivedAudioPackets = 0;
200
- this.deltaReceivedVideoPackets = 0;
201
- this.deltaSentAudioBytes = 0;
202
- this.deltaSentVideoBytes = 0;
203
- this.deltaTransportReceivedBytes = 0;
204
- this.deltaTransportSentBytes = 0;
205
- this.sendingAudioBitrate = 0;
206
- this.sendingVideoBitrate = 0;
207
- this.receivingAudioBitrate = 0;
208
- this.receivingVideoBitrate = 0;
209
- const now = Date.now();
210
- const elapsedTimeInMs = now - this.updated;
211
- const elapsedTimeInSec = elapsedTimeInMs / 1000;
212
- const rttMeasurementsInSec = [];
213
- const jitterMeasurements = [];
214
- if (sample.certificates) {
215
- for (const certificate of sample.certificates) {
216
- this._updateCertificateStats(certificate);
217
- }
218
- }
219
- if (sample.codecs) {
220
- for (const codec of sample.codecs) {
221
- this._updateCodecStats(codec);
222
- }
223
- }
224
- if (sample.dataChannels) {
225
- for (const dataChannel of sample.dataChannels) {
226
- const observedDataChannel = this._updateDataChannelStats(dataChannel);
227
- if (!observedDataChannel)
228
- continue;
229
- this.deltaDataChannelBytesSent += observedDataChannel.deltaBytesSent;
230
- this.deltaDataChannelBytesReceived += observedDataChannel.deltaBytesReceived;
231
- this.deltaDataChannelMessagesSent += observedDataChannel.deltaMessagesSent;
232
- this.deltaDataChannelMessagesReceived += observedDataChannel.deltaMessagesReceived;
233
- }
234
- }
235
- if (sample.iceCandidates) {
236
- for (const iceCandidate of sample.iceCandidates) {
237
- this._updateIceCandidateStats(iceCandidate);
238
- }
239
- }
240
- if (sample.iceCandidatePairs) {
241
- for (const iceCandidatePair of sample.iceCandidatePairs) {
242
- const observedCandidatePair = this._updateIceCandidatePairStats(iceCandidatePair);
243
- if (!observedCandidatePair)
244
- continue;
245
- if (observedCandidatePair.currentRoundTripTime) {
246
- rttMeasurementsInSec.push(observedCandidatePair.currentRoundTripTime);
247
- }
248
- if (observedCandidatePair.availableIncomingBitrate) {
249
- this.availableIncomingBitrate += observedCandidatePair.availableIncomingBitrate;
250
- }
251
- if (observedCandidatePair.availableOutgoingBitrate) {
252
- this.availableOutgoingBitrate += observedCandidatePair.availableOutgoingBitrate;
253
- }
254
- }
255
- }
256
- if (sample.iceTransports) {
257
- for (const iceTransport of sample.iceTransports) {
258
- const observedIceTransport = this._updateIceTransportStats(iceTransport);
259
- if (!observedIceTransport)
260
- return;
261
- observedIceTransport.bytesReceived;
262
- }
263
- }
264
- if (sample.inboundRtps) {
265
- for (const inboundRtp of sample.inboundRtps) {
266
- const observedInboundRtp = this._updateInboundRtpStats(inboundRtp);
267
- if (!observedInboundRtp)
268
- continue;
269
- this.deltaInboundPacketsLost += observedInboundRtp.deltaLostPackets;
270
- this.deltaInboundPacketsReceived += observedInboundRtp.deltaReceivedPackets;
271
- this.deltaInboundReceivedBytes += observedInboundRtp.deltaBytesReceived;
272
- switch (inboundRtp.kind) {
273
- case 'audio':
274
- this.deltaReceivedAudioBytes += observedInboundRtp.deltaBytesReceived;
275
- this.deltaReceivedAudioPackets += observedInboundRtp.deltaReceivedPackets;
276
- break;
277
- case 'video':
278
- this.deltaReceivedVideoBytes += observedInboundRtp.deltaBytesReceived;
279
- this.deltaReceivedVideoPackets += observedInboundRtp.deltaReceivedPackets;
280
- break;
281
- }
282
- if (observedInboundRtp.jitter) {
283
- jitterMeasurements.push(observedInboundRtp.jitter);
284
- }
285
- }
286
- }
287
- if (sample.mediaPlayouts) {
288
- for (const mediaPlayout of sample.mediaPlayouts) {
289
- this._updateMediaPlayoutStats(mediaPlayout);
290
- }
291
- }
292
- if (sample.mediaSources) {
293
- for (const mediaSource of sample.mediaSources) {
294
- this._updateMediaSourceStats(mediaSource);
295
- }
296
- }
297
- if (sample.outboundRtps) {
298
- for (const outboundRtp of sample.outboundRtps) {
299
- const observedOutboundRtp = this._updateOutboundRtpStats(outboundRtp);
300
- if (!observedOutboundRtp)
301
- continue;
302
- this.deltaOutboundPacketsSent += observedOutboundRtp.deltaPacketsSent ?? 0;
303
- this.deltaOutboundSentBytes += observedOutboundRtp.deltaBytesSent ?? 0;
304
- switch (outboundRtp.kind) {
305
- case 'audio':
306
- this.deltaSentAudioBytes += observedOutboundRtp.deltaBytesSent;
307
- this.deltaSentAudioBytes += observedOutboundRtp.deltaPacketsSent;
308
- break;
309
- case 'video':
310
- this.deltaSentVideoBytes += observedOutboundRtp.deltaBytesSent;
311
- this.deltaSentVideoBytes += observedOutboundRtp.deltaPacketsSent;
312
- break;
313
- }
314
- }
315
- }
316
- if (sample.peerConnectionTransports) {
317
- for (const peerConnectionTransport of sample.peerConnectionTransports) {
318
- const observedTransport = this._updatePeerConnectionTransportStats(peerConnectionTransport);
319
- if (!observedTransport)
320
- continue;
321
- }
322
- }
323
- if (sample.remoteInboundRtps) {
324
- for (const remoteInboundRtp of sample.remoteInboundRtps) {
325
- const observedRemoteInboundRtp = this._updateRemoteInboundRtpStats(remoteInboundRtp);
326
- if (!observedRemoteInboundRtp)
327
- continue;
328
- if (observedRemoteInboundRtp.roundTripTime) {
329
- rttMeasurementsInSec.push(observedRemoteInboundRtp.roundTripTime);
330
- }
331
- }
332
- }
333
- if (sample.remoteOutboundRtps) {
334
- for (const remoteOutboundRtp of sample.remoteOutboundRtps) {
335
- const observedRemoteOutboundRtp = this._updateRemoteOutboundRtpStats(remoteOutboundRtp);
336
- if (!observedRemoteOutboundRtp)
337
- continue;
338
- }
339
- }
340
- // tracks should be updated last as they are derived stats
341
- // and depends on base stats but they all received in the sample sample
342
- if (sample.inboundTracks) {
343
- for (const inboundTrack of sample.inboundTracks) {
344
- this._updateInboundTrackSample(inboundTrack);
345
- }
346
- }
347
- if (sample.outboundTracks) {
348
- for (const outboundTrack of sample.outboundTracks) {
349
- this._updateOutboundTrackSample(outboundTrack);
350
- }
351
- }
352
- this.totalInboundPacketsLost += this.deltaInboundPacketsLost;
353
- this.totalInboundPacketsReceived += this.deltaInboundPacketsReceived;
354
- this.totalOutboundPacketsSent += this.deltaOutboundPacketsSent;
355
- this.totalDataChannelBytesSent += this.deltaDataChannelBytesSent;
356
- this.totalDataChannelBytesReceived += this.deltaDataChannelBytesReceived;
357
- this.totalDataChannelMessagesSent += this.deltaDataChannelMessagesSent;
358
- this.totalDataChannelMessagesReceived += this.deltaDataChannelMessagesReceived;
359
- this.totalReceivedAudioBytes += this.deltaReceivedAudioBytes;
360
- this.totalReceivedVideoBytes += this.deltaReceivedVideoBytes;
361
- this.totalSentAudioBytes += this.deltaSentAudioBytes;
362
- this.totalSentVideoBytes += this.deltaSentVideoBytes;
363
- this.totalReceivedAudioPacktes += this.deltaReceivedAudioPackets;
364
- this.totalReceivedVideoPackets += this.deltaReceivedVideoPackets;
365
- this.totalSentAudioPackets += this.deltaSentAudioBytes;
366
- this.totalSentVideoPackets += this.deltaSentVideoBytes;
367
- this.receivingPacketsPerSecond = this.deltaInboundPacketsReceived / elapsedTimeInSec;
368
- this.sendingPacketsPerSecond = this.deltaOutboundPacketsSent / elapsedTimeInSec;
369
- this.sendingAudioBitrate = (this.deltaSentAudioBytes * 8) / elapsedTimeInSec;
370
- this.sendingVideoBitrate = (this.deltaSentVideoBytes * 8) / elapsedTimeInSec;
371
- this.receivingAudioBitrate = (this.deltaReceivedAudioBytes * 8) / elapsedTimeInSec;
372
- this.receivingVideoBitrate = (this.deltaReceivedVideoBytes * 8) / elapsedTimeInSec;
373
- if (rttMeasurementsInSec.length > 0) {
374
- this.currentRttInMs = (0, utils_1.getMedian)(rttMeasurementsInSec, false) * 1000;
375
- }
376
- else {
377
- this.currentRttInMs = undefined;
378
- }
379
- if (jitterMeasurements.length > 0) {
380
- this.currentJitter = (0, utils_1.getMedian)(jitterMeasurements, false);
381
- }
382
- else {
383
- this.currentJitter = undefined;
384
- }
385
- const wasUsingTURN = this.usingTURN;
386
- const selectedIceCandidatePairs = this.selectedIceCandidatePairs;
387
- const selectedCandidatePairForTurn = [];
388
- this.usingTCP = false;
389
- this.usingTURN = false;
390
- for (const selectedCandidatePair of selectedIceCandidatePairs) {
391
- if (selectedCandidatePair.getLocalCandidate()?.protocol === 'tcp') {
392
- this.usingTCP = true;
393
- }
394
- if (selectedCandidatePair.getLocalCandidate()?.candidateType === 'relay' && selectedCandidatePair.getRemoteCandidate()?.url?.startsWith('turn:')) {
395
- selectedCandidatePairForTurn.push(selectedCandidatePair);
396
- this.usingTURN = true;
397
- }
398
- this.deltaTransportReceivedBytes += selectedCandidatePair.deltaBytesReceived;
399
- this.deltaTransportSentBytes += selectedCandidatePair.deltaBytesSent;
400
- }
401
- if (this.usingTURN) {
402
- if (!this.observedTurnServer) {
403
- this.observedTurnServer = this.client.call.observer.observedTURN.addPeerConnection(this);
404
- }
405
- this.observedTurnServer?.updateTurnUsage(...selectedCandidatePairForTurn);
406
- }
407
- else if (wasUsingTURN) {
408
- if (!this.usingTURN) {
409
- this.client.call.observer.observedTURN.removePeerConnection(this);
410
- }
411
- }
412
- this.calculatedScore.value = sample.score;
413
- this.updated = now;
414
- this._checkVisited();
415
- this.emit('update');
416
- }
417
- _checkVisited() {
418
- for (const certificate of [...this.observedCertificates.values()]) {
419
- if (certificate.visited)
420
- continue;
421
- this.observedCertificates.delete(certificate.id);
422
- }
423
- for (const codec of [...this.observedCodecs.values()]) {
424
- if (codec.visited)
425
- continue;
426
- this.observedCodecs.delete(codec.id);
427
- this.emit('removed-codec', codec);
428
- }
429
- for (const dataChannel of [...this.observedDataChannels.values()]) {
430
- if (dataChannel.visited)
431
- continue;
432
- this.observedDataChannels.delete(dataChannel.id);
433
- this.emit('removed-data-channel', dataChannel);
434
- }
435
- for (const iceCandidate of [...this.observedIceCandidates.values()]) {
436
- if (iceCandidate.visited)
437
- continue;
438
- this.observedIceCandidates.delete(iceCandidate.id);
439
- this.emit('removed-ice-candidate', iceCandidate);
440
- }
441
- for (const iceCandidatePair of [...this.observedIceCandidatesPair.values()]) {
442
- if (iceCandidatePair.visited)
443
- continue;
444
- this.observedIceCandidatesPair.delete(iceCandidatePair.id);
445
- this.emit('removed-ice-candidate-pair', iceCandidatePair);
446
- }
447
- for (const iceTransport of [...this.observedIceTransports.values()]) {
448
- if (iceTransport.visited)
449
- continue;
450
- this.observedIceTransports.delete(iceTransport.id);
451
- this.emit('removed-ice-transport', iceTransport);
452
- }
453
- for (const inboundRtp of [...this.observedInboundRtps.values()]) {
454
- if (inboundRtp.visited)
455
- continue;
456
- this.observedInboundRtps.delete(inboundRtp.ssrc);
457
- this.emit('removed-inbound-rtp', inboundRtp);
458
- }
459
- for (const inboundTrack of [...this.observedInboundTracks.values()]) {
460
- if (inboundTrack.visited)
461
- continue;
462
- this.observedInboundTracks.delete(inboundTrack.id);
463
- this.emit('removed-inbound-track', inboundTrack);
464
- }
465
- for (const mediaPlayout of [...this.observedMediaPlayouts.values()]) {
466
- if (mediaPlayout.visited)
467
- continue;
468
- this.observedMediaPlayouts.delete(mediaPlayout.id);
469
- this.emit('removed-media-playout', mediaPlayout);
470
- }
471
- for (const mediaSource of [...this.observedMediaSources.values()]) {
472
- if (mediaSource.visited)
473
- continue;
474
- this.observedMediaSources.delete(mediaSource.id);
475
- this.emit('removed-media-source', mediaSource);
476
- }
477
- for (const outboundRtp of [...this.observedOutboundRtps.values()]) {
478
- if (outboundRtp.visited)
479
- continue;
480
- this.observedOutboundRtps.delete(outboundRtp.ssrc);
481
- this.emit('removed-outbound-rtp', outboundRtp);
482
- }
483
- for (const outboundTrack of [...this.observedOutboundTracks.values()]) {
484
- if (outboundTrack.visited)
485
- continue;
486
- this.observedOutboundTracks.delete(outboundTrack.id);
487
- this.emit('removed-outbound-track', outboundTrack);
488
- }
489
- for (const peerConnectionTransport of [...this.observedPeerConnectionTransports.values()]) {
490
- if (peerConnectionTransport.visited)
491
- continue;
492
- this.observedPeerConnectionTransports.delete(peerConnectionTransport.id);
493
- this.emit('removed-peer-connection-transport', peerConnectionTransport);
494
- }
495
- for (const remoteInboundRtp of [...this.observedRemoteInboundRtps.values()]) {
496
- if (remoteInboundRtp.visited)
497
- continue;
498
- this.observedRemoteInboundRtps.delete(remoteInboundRtp.ssrc);
499
- this.emit('removed-remote-inbound-rtp', remoteInboundRtp);
500
- }
501
- for (const remoteOutboundRtp of [...this.observedRemoteOutboundRtps.values()]) {
502
- if (remoteOutboundRtp.visited)
503
- continue;
504
- this.observedRemoteOutboundRtps.delete(remoteOutboundRtp.ssrc);
505
- this.emit('removed-remote-outbound-rtp', remoteOutboundRtp);
506
- }
507
- }
508
- _updateCertificateStats(stats) {
509
- let observedCertificate = this.observedCertificates.get(stats.id);
510
- if (!observedCertificate) {
511
- if (!stats.timestamp || !stats.id || !stats.fingerprint) {
512
- return logger.warn(`ObservedPeerConnection received an invalid CertificateStats (missing timestamp OR id OR fingerprint field). PeerConnectionId: ${this.peerConnectionId} ClientId: ${this.client.clientId}, CallId: ${this.client.call.callId}`, stats);
513
- }
514
- observedCertificate = new ObservedCertificate_1.ObservedCertificate(stats.timestamp, stats.id, this);
515
- this.observedCertificates.set(stats.id, observedCertificate);
516
- this.emit('added-certificate', observedCertificate);
517
- }
518
- observedCertificate.update(stats);
519
- return observedCertificate;
520
- }
521
- _updateCodecStats(stats) {
522
- let observedCodec = this.observedCodecs.get(stats.id);
523
- if (!observedCodec) {
524
- if (!stats.timestamp || !stats.id || !stats.mimeType) {
525
- return logger.warn(`ObservedPeerConnection received an invalid CodecStats (missing timestamp OR id OR mimeType field). PeerConnectionId: ${this.peerConnectionId} ClientId: ${this.client.clientId}, CallId: ${this.client.call.callId}`, stats);
526
- }
527
- observedCodec = new ObservedCodec_1.ObservedCodec(stats.timestamp, stats.id, stats.mimeType, this);
528
- this.observedCodecs.set(stats.id, observedCodec);
529
- this.emit('added-codec', observedCodec);
530
- }
531
- observedCodec.update(stats);
532
- return observedCodec;
533
- }
534
- _updateDataChannelStats(stats) {
535
- let observedDataChannel = this.observedDataChannels.get(stats.id);
536
- if (!observedDataChannel) {
537
- if (!stats.timestamp || !stats.id) {
538
- return logger.warn(`ObservedPeerConnection received an invalid DataChannelStats (missing timestamp OR id field). PeerConnectionId: ${this.peerConnectionId} ClientId: ${this.client.clientId}, CallId: ${this.client.call.callId}`, stats);
539
- }
540
- observedDataChannel = new ObservedDataChannel_1.ObservedDataChannel(stats.timestamp, stats.id, this);
541
- this.observedDataChannels.set(stats.id, observedDataChannel);
542
- this.emit('added-data-channel', observedDataChannel);
543
- }
544
- observedDataChannel.update(stats);
545
- return observedDataChannel;
546
- }
547
- _updateIceCandidateStats(stats) {
548
- let observedIceCandidate = this.observedIceCandidates.get(stats.id);
549
- if (!observedIceCandidate) {
550
- if (!stats.timestamp || !stats.id) {
551
- return logger.warn(`ObservedPeerConnection received an invalid IceCandidateStats (missing timestamp OR id field). PeerConnectionId: ${this.peerConnectionId} ClientId: ${this.client.clientId}, CallId: ${this.client.call.callId}`, stats);
552
- }
553
- observedIceCandidate = new ObservedIceCandidate_1.ObservedIceCandidate(stats.timestamp, stats.id, this);
554
- this.observedIceCandidates.set(stats.id, observedIceCandidate);
555
- this.emit('added-ice-candidate', observedIceCandidate);
556
- }
557
- observedIceCandidate.update(stats);
558
- return observedIceCandidate;
559
- }
560
- _updateIceCandidatePairStats(stats) {
561
- let observedIceCandidatePair = this.observedIceCandidatesPair.get(stats.id);
562
- if (!observedIceCandidatePair) {
563
- if (!stats.timestamp || !stats.id) {
564
- return logger.warn(`ObservedPeerConnection received an invalid IceCandidateStats (missing timestamp OR id field). PeerConnectionId: ${this.peerConnectionId} ClientId: ${this.client.clientId}, CallId: ${this.client.call.callId}`, stats);
565
- }
566
- observedIceCandidatePair = new ObservedIceCandidatePair_1.ObservedIceCandidatePair(stats.timestamp, stats.id, this);
567
- this.observedIceCandidatesPair.set(stats.id, observedIceCandidatePair);
568
- this.emit('added-ice-candidate-pair', observedIceCandidatePair);
569
- }
570
- observedIceCandidatePair.update(stats);
571
- return observedIceCandidatePair;
572
- }
573
- _updateIceTransportStats(stats) {
574
- let observedIceTransport = this.observedIceTransports.get(stats.id);
575
- if (!observedIceTransport) {
576
- if (!stats.timestamp || !stats.id) {
577
- return logger.warn(`ObservedPeerConnection received an invalid IceCandidateStats (missing timestamp OR id field). PeerConnectionId: ${this.peerConnectionId} ClientId: ${this.client.clientId}, CallId: ${this.client.call.callId}`, stats);
578
- }
579
- observedIceTransport = new ObservedIceTransport_1.ObservedIceTransport(stats.timestamp, stats.id, this);
580
- this.observedIceTransports.set(stats.id, observedIceTransport);
581
- this.emit('added-ice-transport', observedIceTransport);
582
- }
583
- observedIceTransport.update(stats);
584
- return observedIceTransport;
585
- }
586
- _updateInboundRtpStats(stats) {
587
- let observedInboundRtp = this.observedInboundRtps.get(stats.ssrc);
588
- if (!observedInboundRtp) {
589
- if (!stats.timestamp || !stats.id || !stats.ssrc || !stats.kind || !stats.trackIdentifier) {
590
- return logger.warn(`ObservedPeerConnection received an invalid InboundRtpStats (missing timestamp OR id OR ssrc OR kind OR trackIdentifier field). PeerConnectionId: ${this.peerConnectionId} ClientId: ${this.client.clientId}, CallId: ${this.client.call.callId}`, stats);
591
- }
592
- observedInboundRtp = new ObservedInboundRtp_1.ObservedInboundRtp(stats.timestamp, stats.id, stats.ssrc, stats.kind, stats.trackIdentifier, this);
593
- this.observedInboundRtps.set(stats.ssrc, observedInboundRtp);
594
- this.emit('added-inbound-rtp', observedInboundRtp);
595
- }
596
- observedInboundRtp.update(stats);
597
- return observedInboundRtp;
598
- }
599
- _updateInboundTrackSample(stats) {
600
- let observedInboundTrack = this.observedInboundTracks.get(stats.id);
601
- if (!observedInboundTrack) {
602
- if (!stats.timestamp || !stats.id || !stats.kind) {
603
- return logger.warn(`ObservedPeerConnection received an invalid InboundTrackSample (missing timestamp OR id OR kind field). PeerConnectionId: ${this.peerConnectionId} ClientId: ${this.client.clientId}, CallId: ${this.client.call.callId}`, stats);
604
- }
605
- const inboundRtp = [...this.observedInboundRtps.values()].find((inbRtp) => inbRtp.trackIdentifier === stats.id);
606
- const mediaPlayout = inboundRtp ?
607
- [...this.observedMediaPlayouts.values()].find((mp) => mp.id === inboundRtp.playoutId) : undefined;
608
- observedInboundTrack = new ObservedInboundTrack_1.ObservedInboundTrack(stats.timestamp, stats.id, stats.kind, this, inboundRtp, mediaPlayout);
609
- this.observedInboundTracks.set(stats.id, observedInboundTrack);
610
- this.emit('added-inbound-track', observedInboundTrack);
611
- }
612
- observedInboundTrack.update(stats);
613
- return observedInboundTrack;
614
- }
615
- _updateMediaPlayoutStats(stats) {
616
- let observedMediaPlayout = this.observedMediaPlayouts.get(stats.id);
617
- if (!observedMediaPlayout) {
618
- if (!stats.timestamp || !stats.id || !stats.kind) {
619
- return logger.warn(`ObservedPeerConnection received an invalid InboundRtpStats (missing timestamp OR id OR kind OR trackIdentifier field). PeerConnectionId: ${this.peerConnectionId} ClientId: ${this.client.clientId}, CallId: ${this.client.call.callId}`, stats);
620
- }
621
- observedMediaPlayout = new ObservedMediaPlayout_1.ObservedMediaPlayout(stats.timestamp, stats.id, stats.kind, this);
622
- this.observedMediaPlayouts.set(stats.id, observedMediaPlayout);
623
- this.emit('added-media-playout', observedMediaPlayout);
624
- }
625
- observedMediaPlayout.update(stats);
626
- return observedMediaPlayout;
627
- }
628
- _updateMediaSourceStats(stats) {
629
- let observedMediaSource = this.observedMediaSources.get(stats.id);
630
- if (!observedMediaSource) {
631
- if (!stats.timestamp || !stats.id || !stats.kind) {
632
- return logger.warn(`ObservedPeerConnection received an invalid InboundRtpStats (missing timestamp OR id OR kind field). PeerConnectionId: ${this.peerConnectionId} ClientId: ${this.client.clientId}, CallId: ${this.client.call.callId}`, stats);
633
- }
634
- observedMediaSource = new ObservedMediaSource_1.ObservedMediaSource(stats.timestamp, stats.id, stats.kind, this);
635
- this.observedMediaSources.set(stats.id, observedMediaSource);
636
- this.emit('added-media-source', observedMediaSource);
637
- }
638
- observedMediaSource.update(stats);
639
- return observedMediaSource;
640
- }
641
- _updateOutboundRtpStats(stats) {
642
- let observedOutboundRtp = this.observedOutboundRtps.get(stats.ssrc);
643
- if (!observedOutboundRtp) {
644
- if (!stats.timestamp || !stats.id || !stats.ssrc || !stats.kind) {
645
- return logger.warn(`ObservedPeerConnection received an invalid OutboundRtpStats (missing timestamp OR id OR ssrc OR kind field). PeerConnectionId: ${this.peerConnectionId} ClientId: ${this.client.clientId}, CallId: ${this.client.call.callId}`, stats);
646
- }
647
- observedOutboundRtp = new ObservedOutboundRtp_1.ObservedOutboundRtp(stats.timestamp, stats.id, stats.ssrc, stats.kind, this);
648
- this.observedOutboundRtps.set(stats.ssrc, observedOutboundRtp);
649
- this.emit('added-outbound-rtp', observedOutboundRtp);
650
- }
651
- observedOutboundRtp.update(stats);
652
- return observedOutboundRtp;
653
- }
654
- _updateOutboundTrackSample(stats) {
655
- let observedOutboundTrack = this.observedOutboundTracks.get(stats.id);
656
- if (!observedOutboundTrack) {
657
- if (!stats.timestamp || !stats.id || !stats.kind) {
658
- return logger.warn(`ObservedPeerConnection received an invalid OutboundTrackSample (missing timestamp OR id OR kind field). PeerConnectionId: ${this.peerConnectionId} ClientId: ${this.client.clientId}, CallId: ${this.client.call.callId}`, stats);
659
- }
660
- const observedMediaSource = [...this.observedMediaSources.values()].find((mediaSource) => mediaSource.trackIdentifier === stats.id);
661
- const outboundRtps = observedMediaSource
662
- ? [...this.observedOutboundRtps.values()].filter((outboundRtp) => outboundRtp.mediaSourceId === observedMediaSource?.id) : undefined;
663
- observedOutboundTrack = new ObservedOutboundTrack_1.ObservedOutboundTrack(stats.timestamp, stats.id, stats.kind, this, outboundRtps, observedMediaSource);
664
- this.observedOutboundTracks.set(stats.id, observedOutboundTrack);
665
- this.emit('added-outbound-track', observedOutboundTrack);
666
- }
667
- observedOutboundTrack.update(stats);
668
- return observedOutboundTrack;
669
- }
670
- _updatePeerConnectionTransportStats(stats) {
671
- let observedPeerConnectionTransport = this.observedPeerConnectionTransports.get(stats.id);
672
- if (!observedPeerConnectionTransport) {
673
- if (!stats.timestamp || !stats.id) {
674
- return logger.warn(`ObservedPeerConnection received an invalid PeerConnectionTransportStats (missing timestamp OR id field). PeerConnectionId: ${this.peerConnectionId} ClientId: ${this.client.clientId}, CallId: ${this.client.call.callId}`, stats);
675
- }
676
- observedPeerConnectionTransport = new ObservedPeerConnectionTransport_1.ObservedPeerConnectionTransport(stats.timestamp, stats.id, this);
677
- this.observedPeerConnectionTransports.set(stats.id, observedPeerConnectionTransport);
678
- this.emit('added-peer-connection-transport', observedPeerConnectionTransport);
679
- }
680
- observedPeerConnectionTransport.update(stats);
681
- return observedPeerConnectionTransport;
682
- }
683
- _updateRemoteInboundRtpStats(stats) {
684
- let observedRemoteInboundRtp = this.observedRemoteInboundRtps.get(stats.ssrc);
685
- if (!observedRemoteInboundRtp) {
686
- if (!stats.timestamp || !stats.id || !stats.ssrc || !stats.kind) {
687
- return logger.warn(`ObservedPeerConnection received an invalid RemoteInboundRtpStats (missing timestamp OR id OR ssrc OR kind field). PeerConnectionId: ${this.peerConnectionId} ClientId: ${this.client.clientId}, CallId: ${this.client.call.callId}`, stats);
688
- }
689
- observedRemoteInboundRtp = new ObservedRemoteInboundRtp_1.ObservedRemoteInboundRtp(stats.timestamp, stats.id, stats.ssrc, stats.kind, this);
690
- this.observedRemoteInboundRtps.set(stats.ssrc, observedRemoteInboundRtp);
691
- this.emit('added-remote-inbound-rtp', observedRemoteInboundRtp);
692
- }
693
- observedRemoteInboundRtp.update(stats);
694
- return observedRemoteInboundRtp;
695
- }
696
- _updateRemoteOutboundRtpStats(stats) {
697
- let observedRemoteOutboundRtp = this.observedRemoteOutboundRtps.get(stats.ssrc);
698
- if (!observedRemoteOutboundRtp) {
699
- if (!stats.timestamp || !stats.id || !stats.ssrc || !stats.kind) {
700
- return logger.warn(`ObservedPeerConnection received an invalid RemoteOutboundRtpStats (missing timestamp OR id OR ssrc OR kind field). PeerConnectionId: ${this.peerConnectionId} ClientId: ${this.client.clientId}, CallId: ${this.client.call.callId}`, stats);
701
- }
702
- observedRemoteOutboundRtp = new ObservedRemoteOutboundRtp_1.ObservedRemoteOutboundRtp(stats.timestamp, stats.id, stats.ssrc, stats.kind, this);
703
- this.observedRemoteOutboundRtps.set(stats.ssrc, observedRemoteOutboundRtp);
704
- this.emit('added-remote-outbound-rtp', observedRemoteOutboundRtp);
705
- }
706
- observedRemoteOutboundRtp.update(stats);
707
- return observedRemoteOutboundRtp;
708
- }
709
- }
710
- exports.ObservedPeerConnection = ObservedPeerConnection;