@observertc/observer-js 1.0.1-72a904d.0 → 1.0.1-7a83f90.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 (84) hide show
  1. package/lib/ObservedCall.d.ts +4 -8
  2. package/lib/ObservedCall.d.ts.map +1 -1
  3. package/lib/ObservedCall.js +16 -72
  4. package/lib/ObservedCallEventMonitor.d.ts +104 -0
  5. package/lib/ObservedCallEventMonitor.d.ts.map +1 -0
  6. package/lib/ObservedCallEventMonitor.js +314 -0
  7. package/lib/ObservedClient.d.ts +16 -8
  8. package/lib/ObservedClient.d.ts.map +1 -1
  9. package/lib/ObservedClient.js +257 -99
  10. package/lib/ObservedClientEventMonitor.d.ts +89 -0
  11. package/lib/ObservedClientEventMonitor.d.ts.map +1 -0
  12. package/lib/ObservedClientEventMonitor.js +247 -0
  13. package/lib/ObservedDataChannel.d.ts +2 -0
  14. package/lib/ObservedDataChannel.d.ts.map +1 -1
  15. package/lib/ObservedDataChannel.js +2 -0
  16. package/lib/ObservedIceCandidatePair.d.ts +2 -1
  17. package/lib/ObservedIceCandidatePair.d.ts.map +1 -1
  18. package/lib/ObservedIceCandidatePair.js +17 -1
  19. package/lib/ObservedInboundTrack.d.ts +2 -0
  20. package/lib/ObservedInboundTrack.d.ts.map +1 -1
  21. package/lib/ObservedInboundTrack.js +2 -0
  22. package/lib/ObservedOutboundTrack.d.ts +2 -0
  23. package/lib/ObservedOutboundTrack.d.ts.map +1 -1
  24. package/lib/ObservedOutboundTrack.js +2 -0
  25. package/lib/ObservedPeerConnection.d.ts +15 -0
  26. package/lib/ObservedPeerConnection.d.ts.map +1 -1
  27. package/lib/ObservedPeerConnection.js +97 -21
  28. package/lib/Observer.d.ts +9 -7
  29. package/lib/Observer.d.ts.map +1 -1
  30. package/lib/Observer.js +16 -22
  31. package/lib/ObserverEventMonitor.d.ts +130 -0
  32. package/lib/ObserverEventMonitor.d.ts.map +1 -0
  33. package/lib/ObserverEventMonitor.js +404 -0
  34. package/lib/ObserverSummary.d.ts +2 -0
  35. package/lib/ObserverSummary.d.ts.map +1 -1
  36. package/lib/common/utils.d.ts +1 -0
  37. package/lib/common/utils.d.ts.map +1 -1
  38. package/lib/common/utils.js +7 -1
  39. package/lib/index.d.ts +2 -0
  40. package/lib/index.d.ts.map +1 -1
  41. package/lib/index.js +5 -1
  42. package/lib/schema/ClientEventTypes.d.ts +60 -0
  43. package/lib/schema/ClientEventTypes.d.ts.map +1 -1
  44. package/lib/schema/ClientSample.d.ts +1 -1
  45. package/lib/schema/ClientSample.d.ts.map +1 -1
  46. package/lib/updaters/{OnAllCallObserverUpdater_.d.ts → OnAllCallObserverUpdater.d.ts} +3 -1
  47. package/lib/updaters/OnAllCallObserverUpdater.d.ts.map +1 -0
  48. package/lib/updaters/{OnAllCallObserverUpdater_.js → OnAllCallObserverUpdater.js} +13 -1
  49. package/lib/updaters/OnAllClientCallUpdater.d.ts +2 -0
  50. package/lib/updaters/OnAllClientCallUpdater.d.ts.map +1 -1
  51. package/lib/updaters/OnAllClientCallUpdater.js +16 -0
  52. package/lib/updaters/{OnAnyCallObserverUpdater_.d.ts → OnAnyCallObserverUpdater.d.ts} +2 -1
  53. package/lib/updaters/OnAnyCallObserverUpdater.d.ts.map +1 -0
  54. package/lib/updaters/{OnAnyCallObserverUpdater_.js → OnAnyCallObserverUpdater.js} +11 -1
  55. package/lib/updaters/OnAnyClientCallUpdater.d.ts +1 -0
  56. package/lib/updaters/OnAnyClientCallUpdater.d.ts.map +1 -1
  57. package/lib/updaters/OnAnyClientCallUpdater.js +11 -2
  58. package/lib/utils/MediasoupRemoteTrackResolver.d.ts +25 -0
  59. package/lib/utils/MediasoupRemoteTrackResolver.d.ts.map +1 -0
  60. package/lib/utils/MediasoupRemoteTrackResolver.js +110 -0
  61. package/package.json +1 -1
  62. package/src/ObservedCall.ts +56 -82
  63. package/src/ObservedCallEventMonitor.ts +392 -0
  64. package/src/ObservedClient.ts +335 -114
  65. package/src/ObservedClientEventMonitor.ts +301 -0
  66. package/src/ObservedDataChannel.ts +3 -0
  67. package/src/ObservedIceCandidatePair.ts +18 -2
  68. package/src/ObservedInboundTrack.ts +3 -0
  69. package/src/ObservedOutboundTrack.ts +3 -0
  70. package/src/ObservedPeerConnection.ts +115 -40
  71. package/src/Observer.ts +47 -29
  72. package/src/ObserverEventMonitor.ts +518 -0
  73. package/src/ObserverSummary.ts +3 -1
  74. package/src/common/utils.ts +6 -0
  75. package/src/index.ts +2 -0
  76. package/src/schema/ClientEventTypes.ts +64 -0
  77. package/src/schema/ClientSample.ts +1 -1
  78. package/src/updaters/{OnAllCallObserverUpdater_.ts → OnAllCallObserverUpdater.ts} +14 -1
  79. package/src/updaters/OnAllClientCallUpdater.ts +15 -0
  80. package/src/updaters/{OnAnyCallObserverUpdater_.ts → OnAnyCallObserverUpdater.ts} +12 -3
  81. package/src/updaters/OnAnyClientCallUpdater.ts +9 -2
  82. package/src/utils/MediasoupRemoteTrackResolver.ts +155 -0
  83. package/lib/updaters/OnAllCallObserverUpdater_.d.ts.map +0 -1
  84. package/lib/updaters/OnAnyCallObserverUpdater_.d.ts.map +0 -1
@@ -7,7 +7,7 @@ import { CalculatedScore } from './scores/CalculatedScore';
7
7
  import { Detectors } from './detectors/Detectors';
8
8
  import { RemoteTrackResolver } from './utils/RemoteTrackResolver';
9
9
  import { Updater } from './updaters/Updater';
10
- import { ObservedCallSummary } from './ObservedCallSummary';
10
+ import { ObservedCallEventMonitor } from './ObservedCallEventMonitor';
11
11
  export type ObservedCallSettings<AppData extends Record<string, unknown> = Record<string, unknown>> = {
12
12
  callId: string;
13
13
  appData?: AppData;
@@ -21,8 +21,6 @@ export type ObservedCallEvents = {
21
21
  empty: [];
22
22
  'not-empty': [];
23
23
  close: [];
24
- started: [];
25
- ended: [];
26
24
  };
27
25
  export declare interface ObservedCall {
28
26
  on<U extends keyof ObservedCallEvents>(event: U, listener: (...args: ObservedCallEvents[U]) => void): this;
@@ -68,7 +66,8 @@ export declare class ObservedCall<AppData extends Record<string, unknown> = Reco
68
66
  appData: AppData;
69
67
  closed: boolean;
70
68
  startedAt?: number;
71
- ended?: number;
69
+ endedAt?: number;
70
+ closedAt?: number;
72
71
  private _callStartedEvent;
73
72
  private _callEndedEvent;
74
73
  constructor(settings: ObservedCallSettings<AppData>, observer: Observer);
@@ -77,13 +76,10 @@ export declare class ObservedCall<AppData extends Record<string, unknown> = Reco
77
76
  close(): void;
78
77
  getObservedClient<ClientAppData extends Record<string, unknown> = Record<string, unknown>>(clientId: string): ObservedClient<ClientAppData> | undefined;
79
78
  createObservedClient<ClientAppData extends Record<string, unknown> = Record<string, unknown>>(settings: ObservedClientSettings<ClientAppData>): ObservedClient<ClientAppData>;
79
+ createEventMonitor<CTX>(context: CTX): ObservedCallEventMonitor<CTX>;
80
80
  update(): void;
81
81
  private _onClientUpdate;
82
82
  private _clientJoined;
83
83
  private _clientLeft;
84
- emitCallStartedEvent(): void;
85
- emitCallEndedEvent(): void;
86
- resetSummaryMetrics(): void;
87
- createSummary(): ObservedCallSummary;
88
84
  }
89
85
  //# sourceMappingURL=ObservedCall.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ObservedCall.d.ts","sourceRoot":"","sources":["../src/ObservedCall.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAE,cAAc,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAC1E,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAE3D,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAElE,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAE7C,OAA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B;IACF,OAAO,CAAC,eAAe,CAErB;gBAGD,QAAQ,EAAE,oBAAoB,CAAC,OAAO,CAAC,EACvB,QAAQ,EAAE,QAAQ;IA8CnC,IAAW,eAAe,WAEzB;IAED,IAAW,KAAK,uBAEf;IAEM,KAAK;IAaL,iBAAiB,CAAC,aAAa,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,QAAQ,EAAE,MAAM,GAAG,cAAc,CAAC,aAAa,CAAC,GAAG,SAAS;IAMvJ,oBAAoB,CAAC,aAAa,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,QAAQ,EAAE,sBAAsB,CAAC,aAAa,CAAC,GAAG,cAAc,CAAC,aAAa,CAAC;IAsC7K,kBAAkB,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,GAAG,wBAAwB,CAAC,GAAG,CAAC;IAIpE,MAAM;IA2Bb,OAAO,CAAC,eAAe;IA4BvB,OAAO,CAAC,aAAa;IAMrB,OAAO,CAAC,WAAW;CAoDnB"}
@@ -8,6 +8,7 @@ const Detectors_1 = require("./detectors/Detectors");
8
8
  const OnAllClientCallUpdater_1 = require("./updaters/OnAllClientCallUpdater");
9
9
  const OnIntervalUpdater_1 = require("./updaters/OnIntervalUpdater");
10
10
  const OnAnyClientCallUpdater_1 = require("./updaters/OnAnyClientCallUpdater");
11
+ const ObservedCallEventMonitor_1 = require("./ObservedCallEventMonitor");
11
12
  class ObservedCall extends events_1.EventEmitter {
12
13
  observer;
13
14
  detectors;
@@ -49,7 +50,8 @@ class ObservedCall extends events_1.EventEmitter {
49
50
  appData;
50
51
  closed = false;
51
52
  startedAt;
52
- ended;
53
+ endedAt;
54
+ closedAt;
53
55
  _callStartedEvent;
54
56
  _callEndedEvent;
55
57
  constructor(settings, observer) {
@@ -99,12 +101,11 @@ class ObservedCall extends events_1.EventEmitter {
99
101
  close() {
100
102
  if (this.closed)
101
103
  return;
104
+ this.update(); // last update before closing
102
105
  this.closed = true;
103
106
  this.updater?.close();
104
107
  [...this.observedClients.values()].forEach((client) => client.close());
105
- // make sure to emit the events
106
- this.emitCallStartedEvent();
107
- this.emitCallEndedEvent();
108
+ this.closedAt = Date.now();
108
109
  this.emit('close');
109
110
  }
110
111
  getObservedClient(clientId) {
@@ -130,7 +131,7 @@ class ObservedCall extends events_1.EventEmitter {
130
131
  if (this.observedClients.size === 0) {
131
132
  this.emit('empty');
132
133
  }
133
- --this.totalRemovedClients;
134
+ ++this.totalRemovedClients;
134
135
  });
135
136
  result.on('update', onUpdate);
136
137
  result.on('joined', joined);
@@ -144,6 +145,9 @@ class ObservedCall extends events_1.EventEmitter {
144
145
  }
145
146
  return result;
146
147
  }
148
+ createEventMonitor(context) {
149
+ return new ObservedCallEventMonitor_1.ObservedCallEventMonitor(this, context);
150
+ }
147
151
  update() {
148
152
  if (this.closed)
149
153
  return;
@@ -156,9 +160,6 @@ class ObservedCall extends events_1.EventEmitter {
156
160
  this.numberOfOutboundRtpStreams += client.numberOfOutboundRtpStreams;
157
161
  this.numberOfPeerConnections += client.numberOfPeerConnections;
158
162
  this.numberOfDataChannels += client.numberOfDataChannels;
159
- if (client.usingTURN) {
160
- this.clientsUsedTurn.add(client.clientId);
161
- }
162
163
  }
163
164
  this.detectors.update();
164
165
  this.scoreCalculator.update();
@@ -171,12 +172,12 @@ class ObservedCall extends events_1.EventEmitter {
171
172
  }
172
173
  _onClientUpdate(client) {
173
174
  this.totalClientsReceivedAudioBytes += client.deltaReceivedAudioBytes;
174
- this.totalClientsSentAudioBytes += client.deltaSentAudioBytes;
175
175
  this.totalClientsReceivedVideoBytes += client.deltaReceivedVideoBytes;
176
- this.totalClientsReceivedVideoBytes += client.deltaSentVideoBytes;
177
176
  this.totalClientsReceivedDataChannelBytes += client.deltaDataChannelBytesReceived;
178
- this.totalClientsSentDataChannelBytes += client.deltaDataChannelBytesSent;
179
177
  this.totalClientsReceivedBytes += client.deltaTransportReceivedBytes;
178
+ this.totalClientsSentAudioBytes += client.deltaSentAudioBytes;
179
+ this.totalClientsSentVideoBytes += client.deltaSentVideoBytes;
180
+ this.totalClientsSentDataChannelBytes += client.deltaDataChannelBytesSent;
180
181
  this.totalClientsSentBytes += client.deltaTransportSentBytes;
181
182
  this.deltaRttLt50Measurements += client.deltaRttLt50Measurements;
182
183
  this.deltaRttLt150Measurements += client.deltaRttLt150Measurements;
@@ -188,76 +189,19 @@ class ObservedCall extends events_1.EventEmitter {
188
189
  this.totalRttGtOrEq300Measurements += client.deltaRttGtOrEq300Measurements;
189
190
  this.deltaNumberOfIssues += client.deltaNumberOfIssues;
190
191
  this.numberOfIssues += client.deltaNumberOfIssues;
192
+ if (client.usingTURN) {
193
+ this.clientsUsedTurn.add(client.clientId);
194
+ }
191
195
  }
192
196
  _clientJoined(client) {
193
197
  if (!client.joinedAt)
194
198
  return;
195
199
  this.startedAt = Math.min(this.startedAt ?? client.joinedAt, client.joinedAt);
196
- if (this._callStartedEvent.emitted)
197
- return;
198
- if (this._callStartedEvent.timer) {
199
- if (1 < this.observedClients.size) {
200
- this.emitCallStartedEvent();
201
- }
202
- return;
203
- }
204
- this._callStartedEvent.timer = setTimeout(() => {
205
- this.emitCallStartedEvent();
206
- }, 5000);
207
200
  }
208
201
  _clientLeft(client) {
209
202
  if (!client.leftAt)
210
203
  return;
211
- this.ended = Math.max(this.ended ?? client.leftAt, client.leftAt);
212
- }
213
- emitCallStartedEvent() {
214
- if (this._callStartedEvent.emitted)
215
- return;
216
- this._callStartedEvent.emitted = true;
217
- clearTimeout(this._callStartedEvent.timer);
218
- this._callStartedEvent.timer = undefined;
219
- this.emit('started');
220
- }
221
- emitCallEndedEvent() {
222
- if (this._callEndedEvent.emitted)
223
- return;
224
- this._callEndedEvent.emitted = true;
225
- this.emit('ended');
226
- }
227
- resetSummaryMetrics() {
228
- this.totalAddedClients = 0;
229
- this.totalRemovedClients = 0;
230
- this.totalClientsReceivedAudioBytes = 0;
231
- this.totalClientsReceivedVideoBytes = 0;
232
- this.totalClientsReceivedBytes = 0;
233
- this.totalClientsSentAudioBytes = 0;
234
- this.totalClientsSentVideoBytes = 0;
235
- this.totalClientsSentBytes = 0;
236
- this.totalRttLt50Measurements = 0;
237
- this.totalRttLt150Measurements = 0;
238
- this.totalRttLt300Measurements = 0;
239
- this.totalRttGtOrEq300Measurements = 0;
240
- this.numberOfIssues = 0;
241
- this.clientsUsedTurn.clear();
242
- }
243
- createSummary() {
244
- return {
245
- currentActiveClients: this.observedClients.size,
246
- totalAddedClients: this.totalAddedClients,
247
- totalRemovedClients: this.totalRemovedClients,
248
- totalClientsReceivedAudioBytes: this.totalClientsReceivedBytes,
249
- totalClientsReceivedVideoBytes: this.totalClientsReceivedVideoBytes,
250
- totalClientsReceivedBytes: this.totalClientsReceivedBytes,
251
- totalClientsSentAudioBytes: this.totalClientsSentAudioBytes,
252
- totalClientsSentVideoBytes: this.totalClientsSentVideoBytes,
253
- totalClientsSentBytes: this.totalClientsSentBytes,
254
- totalRttLt50Measurements: this.totalRttLt50Measurements,
255
- totalRttLt150Measurements: this.totalRttLt150Measurements,
256
- totalRttLt300Measurements: this.totalRttLt300Measurements,
257
- totalRttGtOrEq300Measurements: this.totalRttGtOrEq300Measurements,
258
- numberOfIssues: this.numberOfIssues,
259
- numberOfClientsUsedTurn: this.clientsUsedTurn.size,
260
- };
204
+ this.endedAt = Math.max(this.endedAt ?? client.leftAt, client.leftAt);
261
205
  }
262
206
  }
263
207
  exports.ObservedCall = ObservedCall;
@@ -0,0 +1,104 @@
1
+ import { ObservedCall } from './ObservedCall';
2
+ import { ObservedCertificate } from './ObservedCertificate';
3
+ import { ObservedClient } from './ObservedClient';
4
+ import { ObservedCodec } from './ObservedCodec';
5
+ import { ObservedDataChannel } from './ObservedDataChannel';
6
+ import { ObservedIceCandidate } from './ObservedIceCandidate';
7
+ import { ObservedIceCandidatePair } from './ObservedIceCandidatePair';
8
+ import { ObservedIceTransport } from './ObservedIceTransport';
9
+ import { ObservedInboundRtp } from './ObservedInboundRtp';
10
+ import { ObservedInboundTrack } from './ObservedInboundTrack';
11
+ import { ObservedMediaPlayout } from './ObservedMediaPlayout';
12
+ import { ObservedMediaSource } from './ObservedMediaSource';
13
+ import { ObservedOutboundRtp } from './ObservedOutboundRtp';
14
+ import { ObservedOutboundTrack } from './ObservedOutboundTrack';
15
+ import { ObservedPeerConnection } from './ObservedPeerConnection';
16
+ import { ClientEvent, ClientIssue, ClientMetaData, ClientSample, ExtensionStat } from './schema/ClientSample';
17
+ export declare class ObservedCallEventMonitor<Context> {
18
+ readonly call: ObservedCall;
19
+ readonly context: Context;
20
+ constructor(call: ObservedCall, context: Context);
21
+ onCallClosed?: (call: ObservedCall, ctx: Context) => void;
22
+ onCallEmpty?: (call: ObservedCall, ctx: Context) => void;
23
+ onCallNotEmpty?: (call: ObservedCall, ctx: Context) => void;
24
+ onCallUpdated?: (call: ObservedCall, ctx: Context) => void;
25
+ onClientAdded?: (client: ObservedClient, ctx: Context) => void;
26
+ onClientClosed?: (client: ObservedClient, ctx: Context) => void;
27
+ onClientRejoined?: (client: ObservedClient, ctx: Context) => void;
28
+ onClientIssue?: (observedClent: ObservedClient, issue: ClientIssue, ctx: Context) => void;
29
+ onClientMetadata?: (observedClient: ObservedClient, metadata: ClientMetaData, ctx: Context) => void;
30
+ onClientExtensionStats?: (observedClient: ObservedClient, extensionStats: ExtensionStat, ctx: Context) => void;
31
+ onClientJoined?: (client: ObservedClient, ctx: Context) => void;
32
+ onClientLeft?: (client: ObservedClient, ctx: Context) => void;
33
+ onClientUserMediaError?: (observedClient: ObservedClient, error: string, ctx: Context) => void;
34
+ onClientUsingTurn?: (client: ObservedClient, usingTurn: boolean, ctx: Context) => void;
35
+ onClientUpdated?: (client: ObservedClient, sample: ClientSample, ctx: Context) => void;
36
+ onClientEvent?: (client: ObservedClient, event: ClientEvent, ctx: Context) => void;
37
+ onPeerConnectionAdded?: (peerConnection: ObservedPeerConnection, ctx: Context) => void;
38
+ onPeerConnectionRemoved?: (peerConnection: ObservedPeerConnection, ctx: Context) => void;
39
+ onSelectedCandidatePairChanged?: (peerConnection: ObservedPeerConnection, ctx: Context) => void;
40
+ onIceGatheringStateChange?: (peerConnection: ObservedPeerConnection, ctx: Context) => void;
41
+ onIceConnectionStateChange?: (peerConnection: ObservedPeerConnection, ctx: Context) => void;
42
+ onConnectionStateChange?: (peerConnection: ObservedPeerConnection, ctx: Context) => void;
43
+ onCertificateAdded?: (certificate: ObservedCertificate, ctx: Context) => void;
44
+ onCertificateRemoved?: (certificate: ObservedCertificate, ctx: Context) => void;
45
+ onInboundTrackAdded?: (inboundTrack: ObservedInboundTrack, ctx: Context) => void;
46
+ onInboundTrackRemoved?: (inboundTrack: ObservedInboundTrack, ctx: Context) => void;
47
+ onOutboundTrackAdded?: (outboundTrack: ObservedOutboundTrack, ctx: Context) => void;
48
+ onOutboundTrackRemoved?: (outboundTrack: ObservedOutboundTrack, ctx: Context) => void;
49
+ onInboundRtpAdded?: (inboundRtp: ObservedInboundRtp, ctx: Context) => void;
50
+ onInboundRtpRemoved?: (inboundRtp: ObservedInboundRtp, ctx: Context) => void;
51
+ onOutboundRtpAdded?: (outboundRtp: ObservedOutboundRtp, ctx: Context) => void;
52
+ onOutboundRtpRemoved?: (outboundRtp: ObservedOutboundRtp, ctx: Context) => void;
53
+ onDataChannelAdded?: (dataChannel: ObservedDataChannel, ctx: Context) => void;
54
+ onDataChannelRemoved?: (dataChannel: ObservedDataChannel, ctx: Context) => void;
55
+ onAddedIceTransport?: (iceTransport: ObservedIceTransport, ctx: Context) => void;
56
+ onRemovedIceTransport?: (iceTransport: ObservedIceTransport, ctx: Context) => void;
57
+ onIceCandidateAdded?: (iceCandidate: ObservedIceCandidate, ctx: Context) => void;
58
+ onIceCandidateRemoved?: (iceCandidate: ObservedIceCandidate, ctx: Context) => void;
59
+ onAddedIceCandidatePair?: (candidatePair: ObservedIceCandidatePair, ctx: Context) => void;
60
+ onRemovedIceCandidatePair?: (candidatePair: ObservedIceCandidatePair, ctx: Context) => void;
61
+ onAddedMediaCodec?: (codec: ObservedCodec, ctx: Context) => void;
62
+ onRemovedMediaCodec?: (codec: ObservedCodec, ctx: Context) => void;
63
+ onAddedMediaPlayout?: (mediaPlayout: ObservedMediaPlayout, ctx: Context) => void;
64
+ onRemovedMediaPlayout?: (mediaPlayout: ObservedMediaPlayout, ctx: Context) => void;
65
+ onMediaSourceAdded?: (mediaSource: ObservedMediaSource, ctx: Context) => void;
66
+ onMediaSourceRemoved?: (mediaSource: ObservedMediaSource, ctx: Context) => void;
67
+ private _onCallAdded;
68
+ private _onClientAdded;
69
+ private _onClientRejoined;
70
+ private _onPeerConnconnectionAdded;
71
+ private _onPeerConnectionRemoved;
72
+ private _onCertificateAdded;
73
+ private _onCertificateRemoved;
74
+ private _onInboundTrackAdded;
75
+ private _onInboundTrackRemoved;
76
+ private _onOutboundTrackAdded;
77
+ private _onOutboundTrackRemoved;
78
+ private _onInboundRtpAdded;
79
+ private _onInboundRtpRemoved;
80
+ private _onOutboundRtpAdded;
81
+ private _onOutboundRtpRemoved;
82
+ private _onDataChannelAdded;
83
+ private _onDataChannelRemoved;
84
+ private _onAddedIceTransport;
85
+ private _onRemovedIceTransport;
86
+ private _onIceCandidateAdded;
87
+ private _onIceCandidateRemoved;
88
+ private _onAddedIceCandidatePair;
89
+ private _onRemovedIceCandidatePair;
90
+ private _onAddedMediaCodec;
91
+ private _onRemovedMediaCodec;
92
+ private _onAddedMediaPlayout;
93
+ private _onRemovedMediaPlayout;
94
+ private _onMediaSourceAdded;
95
+ private _onMediaSourceRemoved;
96
+ private _onClientIssue;
97
+ private _onClientMetadata;
98
+ private _onClientExtensionStats;
99
+ private _onClientJoined;
100
+ private _onClientLeft;
101
+ private _onUserMediaError;
102
+ private _onUsingTurn;
103
+ }
104
+ //# sourceMappingURL=ObservedCallEventMonitor.d.ts.map
@@ -0,0 +1 @@
1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B,OAAO,CAAC,oBAAoB;IAI5B,OAAO,CAAC,sBAAsB;IAI9B,OAAO,CAAC,wBAAwB;IAIhC,OAAO,CAAC,0BAA0B;IAIlC,OAAO,CAAC,kBAAkB;IAI1B,OAAO,CAAC,oBAAoB;IAI5B,OAAO,CAAC,oBAAoB;IAI5B,OAAO,CAAC,sBAAsB;IAI9B,OAAO,CAAC,mBAAmB;IAI3B,OAAO,CAAC,qBAAqB;IAI7B,OAAO,CAAC,cAAc;IAItB,OAAO,CAAC,iBAAiB;IAIzB,OAAO,CAAC,uBAAuB;IAI/B,OAAO,CAAC,eAAe;IAIvB,OAAO,CAAC,aAAa;IAIrB,OAAO,CAAC,iBAAiB;IAIzB,OAAO,CAAC,YAAY;CAGpB"}
@@ -0,0 +1,314 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ObservedCallEventMonitor = void 0;
4
+ class ObservedCallEventMonitor {
5
+ call;
6
+ context;
7
+ constructor(call, context) {
8
+ this.call = call;
9
+ this.context = context;
10
+ this._onPeerConnconnectionAdded = this._onPeerConnconnectionAdded.bind(this);
11
+ this._onPeerConnectionRemoved = this._onPeerConnectionRemoved.bind(this);
12
+ this._onCertificateAdded = this._onCertificateAdded.bind(this);
13
+ this._onCertificateRemoved = this._onCertificateRemoved.bind(this);
14
+ this._onInboundTrackAdded = this._onInboundTrackAdded.bind(this);
15
+ this._onInboundTrackRemoved = this._onInboundTrackRemoved.bind(this);
16
+ this._onOutboundTrackAdded = this._onOutboundTrackAdded.bind(this);
17
+ this._onOutboundTrackRemoved = this._onOutboundTrackRemoved.bind(this);
18
+ this._onInboundRtpAdded = this._onInboundRtpAdded.bind(this);
19
+ this._onInboundRtpRemoved = this._onInboundRtpRemoved.bind(this);
20
+ this._onOutboundRtpAdded = this._onOutboundRtpAdded.bind(this);
21
+ this._onOutboundRtpRemoved = this._onOutboundRtpRemoved.bind(this);
22
+ this._onDataChannelAdded = this._onDataChannelAdded.bind(this);
23
+ this._onDataChannelRemoved = this._onDataChannelRemoved.bind(this);
24
+ this._onAddedIceTransport = this._onAddedIceTransport.bind(this);
25
+ this._onRemovedIceTransport = this._onRemovedIceTransport.bind(this);
26
+ this._onIceCandidateAdded = this._onIceCandidateAdded.bind(this);
27
+ this._onIceCandidateRemoved = this._onIceCandidateRemoved.bind(this);
28
+ this._onAddedIceCandidatePair = this._onAddedIceCandidatePair.bind(this);
29
+ this._onRemovedIceCandidatePair = this._onRemovedIceCandidatePair.bind(this);
30
+ this._onAddedMediaCodec = this._onAddedMediaCodec.bind(this);
31
+ this._onRemovedMediaCodec = this._onRemovedMediaCodec.bind(this);
32
+ this._onAddedMediaPlayout = this._onAddedMediaPlayout.bind(this);
33
+ this._onRemovedMediaPlayout = this._onRemovedMediaPlayout.bind(this);
34
+ this._onMediaSourceAdded = this._onMediaSourceAdded.bind(this);
35
+ this._onMediaSourceRemoved = this._onMediaSourceRemoved.bind(this);
36
+ this._onClientIssue = this._onClientIssue.bind(this);
37
+ this._onClientMetadata = this._onClientMetadata.bind(this);
38
+ this._onClientJoined = this._onClientJoined.bind(this);
39
+ this._onClientLeft = this._onClientLeft.bind(this);
40
+ this._onUserMediaError = this._onUserMediaError.bind(this);
41
+ this._onUsingTurn = this._onUsingTurn.bind(this);
42
+ this._onClientAdded = this._onClientAdded.bind(this);
43
+ this._onCallAdded = this._onCallAdded.bind(this);
44
+ this._onClientRejoined = this._onClientRejoined.bind(this);
45
+ this._onClientExtensionStats = this._onClientExtensionStats.bind(this);
46
+ this._onCallAdded(call);
47
+ }
48
+ // Public event handlers
49
+ onCallClosed;
50
+ onCallEmpty;
51
+ onCallNotEmpty;
52
+ onCallUpdated;
53
+ onClientAdded;
54
+ onClientClosed;
55
+ onClientRejoined;
56
+ onClientIssue;
57
+ onClientMetadata;
58
+ onClientExtensionStats;
59
+ onClientJoined;
60
+ onClientLeft;
61
+ onClientUserMediaError;
62
+ onClientUsingTurn;
63
+ onClientUpdated;
64
+ onClientEvent;
65
+ onPeerConnectionAdded;
66
+ onPeerConnectionRemoved;
67
+ onSelectedCandidatePairChanged;
68
+ onIceGatheringStateChange;
69
+ onIceConnectionStateChange;
70
+ onConnectionStateChange;
71
+ onCertificateAdded;
72
+ onCertificateRemoved;
73
+ onInboundTrackAdded;
74
+ onInboundTrackRemoved;
75
+ onOutboundTrackAdded;
76
+ onOutboundTrackRemoved;
77
+ onInboundRtpAdded;
78
+ onInboundRtpRemoved;
79
+ onOutboundRtpAdded;
80
+ onOutboundRtpRemoved;
81
+ onDataChannelAdded;
82
+ onDataChannelRemoved;
83
+ onAddedIceTransport;
84
+ onRemovedIceTransport;
85
+ onIceCandidateAdded;
86
+ onIceCandidateRemoved;
87
+ onAddedIceCandidatePair;
88
+ onRemovedIceCandidatePair;
89
+ onAddedMediaCodec;
90
+ onRemovedMediaCodec;
91
+ onAddedMediaPlayout;
92
+ onRemovedMediaPlayout;
93
+ onMediaSourceAdded;
94
+ onMediaSourceRemoved;
95
+ _onCallAdded(call) {
96
+ const onCallEmpty = () => this.onCallEmpty?.(call, this.context);
97
+ const onCallNotEmpty = () => this.onCallNotEmpty?.(call, this.context);
98
+ const onCallUpdated = () => this.onCallUpdated?.(call, this.context);
99
+ call.once('close', () => {
100
+ call.off('newclient', this._onClientAdded);
101
+ call.off('empty', onCallEmpty);
102
+ call.off('not-empty', onCallNotEmpty);
103
+ call.off('update', onCallUpdated);
104
+ this.onCallClosed?.(call, this.context);
105
+ });
106
+ call.on('newclient', this._onClientAdded);
107
+ call.on('empty', onCallEmpty);
108
+ call.on('not-empty', onCallNotEmpty);
109
+ call.on('update', onCallUpdated);
110
+ }
111
+ _onClientAdded(observedClient) {
112
+ const onClientIssue = (issue) => this._onClientIssue(observedClient, issue);
113
+ const onClientMetadata = (metaData) => this._onClientMetadata(observedClient, metaData);
114
+ const onClientJoined = () => this._onClientJoined(observedClient);
115
+ const onClientLeft = () => this._onClientLeft(observedClient);
116
+ const onClientRejoined = () => this._onClientRejoined(observedClient);
117
+ const onClientExtensionStats = (extensionStats) => this._onClientExtensionStats(observedClient, extensionStats);
118
+ const onUsingTurn = (usingTurn) => this._onUsingTurn(observedClient, usingTurn);
119
+ const onUserMediaError = (error) => this._onUserMediaError(observedClient, error);
120
+ const onClientUpdated = (...args) => this.onClientUpdated?.(observedClient, args[0].sample, this.context);
121
+ const onClientEvent = (event) => this.onClientEvent?.(observedClient, event, this.context);
122
+ observedClient.once('close', () => {
123
+ observedClient.off('newpeerconnection', this._onPeerConnconnectionAdded);
124
+ observedClient.off('issue', onClientIssue);
125
+ observedClient.off('metaData', onClientMetadata);
126
+ observedClient.off('joined', onClientJoined);
127
+ observedClient.off('left', onClientLeft);
128
+ observedClient.off('rejoined', onClientJoined);
129
+ observedClient.off('usermediaerror', onUserMediaError);
130
+ observedClient.off('usingturn', onUsingTurn);
131
+ observedClient.off('update', onClientUpdated);
132
+ observedClient.off('clientEvent', onClientEvent);
133
+ this.onClientClosed?.(observedClient, this.context);
134
+ });
135
+ observedClient.on('newpeerconnection', this._onPeerConnconnectionAdded);
136
+ observedClient.on('issue', onClientIssue);
137
+ observedClient.on('metaData', onClientMetadata);
138
+ observedClient.on('joined', onClientJoined);
139
+ observedClient.on('left', onClientLeft);
140
+ observedClient.on('rejoined', onClientRejoined);
141
+ observedClient.on('usermediaerror', onUserMediaError);
142
+ observedClient.on('usingturn', onUsingTurn);
143
+ observedClient.on('extensionStats', onClientExtensionStats);
144
+ observedClient.on('update', onClientUpdated);
145
+ observedClient.on('clientEvent', onClientEvent);
146
+ this.onClientAdded?.(observedClient, this.context);
147
+ }
148
+ _onClientRejoined(observedClient) {
149
+ this.onClientRejoined?.(observedClient, this.context);
150
+ }
151
+ _onPeerConnconnectionAdded(peerConnection) {
152
+ const onSelectedCandidatePairChanged = () => this.onSelectedCandidatePairChanged?.(peerConnection, this.context);
153
+ const onIceGatheringStateChange = () => this.onIceGatheringStateChange?.(peerConnection, this.context);
154
+ const onIceConnectionStateChange = () => this.onIceConnectionStateChange?.(peerConnection, this.context);
155
+ const onConnectionStateChange = () => this.onConnectionStateChange?.(peerConnection, this.context);
156
+ peerConnection.once('close', () => {
157
+ peerConnection.off('added-certificate', this._onCertificateAdded);
158
+ peerConnection.off('removed-certificate', this._onCertificateRemoved);
159
+ peerConnection.off('added-inbound-track', this._onInboundTrackAdded);
160
+ peerConnection.off('removed-inbound-track', this._onInboundTrackRemoved);
161
+ peerConnection.off('added-outbound-track', this._onOutboundTrackAdded);
162
+ peerConnection.off('removed-outbound-track', this._onOutboundTrackRemoved);
163
+ peerConnection.off('added-inbound-rtp', this._onInboundRtpAdded);
164
+ peerConnection.off('removed-inbound-rtp', this._onInboundRtpRemoved);
165
+ peerConnection.off('added-outbound-rtp', this._onOutboundRtpAdded);
166
+ peerConnection.off('removed-outbound-rtp', this._onOutboundRtpRemoved);
167
+ peerConnection.off('added-data-channel', this._onDataChannelAdded);
168
+ peerConnection.off('removed-data-channel', this._onDataChannelRemoved);
169
+ peerConnection.off('added-ice-transport', this._onAddedIceTransport);
170
+ peerConnection.off('removed-ice-transport', this._onRemovedIceTransport);
171
+ peerConnection.off('added-ice-candidate', this._onIceCandidateAdded);
172
+ peerConnection.off('removed-ice-candidate', this._onIceCandidateRemoved);
173
+ peerConnection.off('added-ice-candidate-pair', this._onAddedIceCandidatePair);
174
+ peerConnection.off('removed-ice-candidate-pair', this._onRemovedIceCandidatePair);
175
+ peerConnection.off('added-codec', this._onAddedMediaCodec);
176
+ peerConnection.off('removed-codec', this._onRemovedMediaCodec);
177
+ peerConnection.off('added-media-playout', this._onAddedMediaPlayout);
178
+ peerConnection.off('removed-media-playout', this._onRemovedMediaPlayout);
179
+ peerConnection.off('added-media-source', this._onMediaSourceAdded);
180
+ peerConnection.off('removed-media-source', this._onMediaSourceRemoved);
181
+ peerConnection.off('selectedcandidatepair', onSelectedCandidatePairChanged);
182
+ peerConnection.off('icegatheringstatechange', onIceGatheringStateChange);
183
+ peerConnection.off('iceconnectionstatechange', onIceConnectionStateChange);
184
+ peerConnection.off('connectionstatechange', onConnectionStateChange);
185
+ this.onPeerConnectionRemoved?.(peerConnection, this.context);
186
+ });
187
+ peerConnection.on('added-certificate', this._onCertificateAdded);
188
+ peerConnection.on('removed-certificate', this._onCertificateRemoved);
189
+ peerConnection.on('added-inbound-track', this._onInboundTrackAdded);
190
+ peerConnection.on('removed-inbound-track', this._onInboundTrackRemoved);
191
+ peerConnection.on('added-outbound-track', this._onOutboundTrackAdded);
192
+ peerConnection.on('removed-outbound-track', this._onOutboundTrackRemoved);
193
+ peerConnection.on('added-inbound-rtp', this._onInboundRtpAdded);
194
+ peerConnection.on('removed-inbound-rtp', this._onInboundRtpRemoved);
195
+ peerConnection.on('added-outbound-rtp', this._onOutboundRtpAdded);
196
+ peerConnection.on('removed-outbound-rtp', this._onOutboundRtpRemoved);
197
+ peerConnection.on('added-data-channel', this._onDataChannelAdded);
198
+ peerConnection.on('removed-data-channel', this._onDataChannelRemoved);
199
+ peerConnection.on('added-ice-transport', this._onAddedIceTransport);
200
+ peerConnection.on('removed-ice-transport', this._onRemovedIceTransport);
201
+ peerConnection.on('added-ice-candidate', this._onIceCandidateAdded);
202
+ peerConnection.on('removed-ice-candidate', this._onIceCandidateRemoved);
203
+ peerConnection.on('added-ice-candidate-pair', this._onAddedIceCandidatePair);
204
+ peerConnection.on('removed-ice-candidate-pair', this._onRemovedIceCandidatePair);
205
+ peerConnection.on('added-codec', this._onAddedMediaCodec);
206
+ peerConnection.on('removed-codec', this._onRemovedMediaCodec);
207
+ peerConnection.on('added-media-playout', this._onAddedMediaPlayout);
208
+ peerConnection.on('removed-media-playout', this._onRemovedMediaPlayout);
209
+ peerConnection.on('added-media-source', this._onMediaSourceAdded);
210
+ peerConnection.on('removed-media-source', this._onMediaSourceRemoved);
211
+ peerConnection.on('selectedcandidatepair', onSelectedCandidatePairChanged);
212
+ peerConnection.on('icegatheringstatechange', onIceGatheringStateChange);
213
+ peerConnection.on('iceconnectionstatechange', onIceConnectionStateChange);
214
+ peerConnection.on('connectionstatechange', onConnectionStateChange);
215
+ this.onPeerConnectionAdded?.(peerConnection, this.context);
216
+ }
217
+ _onPeerConnectionRemoved(peerConnection) {
218
+ this.onPeerConnectionRemoved?.(peerConnection, this.context);
219
+ }
220
+ _onCertificateAdded(certificate) {
221
+ this.onCertificateAdded?.(certificate, this.context);
222
+ }
223
+ _onCertificateRemoved(certificate) {
224
+ this.onCertificateRemoved?.(certificate, this.context);
225
+ }
226
+ _onInboundTrackAdded(inboundTrack) {
227
+ this.onInboundTrackAdded?.(inboundTrack, this.context);
228
+ }
229
+ _onInboundTrackRemoved(inboundTrack) {
230
+ this.onInboundTrackRemoved?.(inboundTrack, this.context);
231
+ }
232
+ _onOutboundTrackAdded(outboundTrack) {
233
+ this.onOutboundTrackAdded?.(outboundTrack, this.context);
234
+ }
235
+ _onOutboundTrackRemoved(outboundTrack) {
236
+ this.onOutboundTrackRemoved?.(outboundTrack, this.context);
237
+ }
238
+ _onInboundRtpAdded(inboundRtp) {
239
+ this.onInboundRtpAdded?.(inboundRtp, this.context);
240
+ }
241
+ _onInboundRtpRemoved(inboundRtp) {
242
+ this.onInboundRtpRemoved?.(inboundRtp, this.context);
243
+ }
244
+ _onOutboundRtpAdded(outboundRtp) {
245
+ this.onOutboundRtpAdded?.(outboundRtp, this.context);
246
+ }
247
+ _onOutboundRtpRemoved(outboundRtp) {
248
+ this.onOutboundRtpRemoved?.(outboundRtp, this.context);
249
+ }
250
+ _onDataChannelAdded(dataChannel) {
251
+ this.onDataChannelAdded?.(dataChannel, this.context);
252
+ }
253
+ _onDataChannelRemoved(dataChannel) {
254
+ this.onDataChannelRemoved?.(dataChannel, this.context);
255
+ }
256
+ _onAddedIceTransport(iceTransport) {
257
+ this.onAddedIceTransport?.(iceTransport, this.context);
258
+ }
259
+ _onRemovedIceTransport(iceTransport) {
260
+ this.onRemovedIceTransport?.(iceTransport, this.context);
261
+ }
262
+ _onIceCandidateAdded(iceCandidate) {
263
+ this.onIceCandidateAdded?.(iceCandidate, this.context);
264
+ }
265
+ _onIceCandidateRemoved(iceCandidate) {
266
+ this.onIceCandidateRemoved?.(iceCandidate, this.context);
267
+ }
268
+ _onAddedIceCandidatePair(candidatePair) {
269
+ this.onAddedIceCandidatePair?.(candidatePair, this.context);
270
+ }
271
+ _onRemovedIceCandidatePair(candidatePair) {
272
+ this.onRemovedIceCandidatePair?.(candidatePair, this.context);
273
+ }
274
+ _onAddedMediaCodec(codec) {
275
+ this.onAddedMediaCodec?.(codec, this.context);
276
+ }
277
+ _onRemovedMediaCodec(codec) {
278
+ this.onRemovedMediaCodec?.(codec, this.context);
279
+ }
280
+ _onAddedMediaPlayout(mediaPlayout) {
281
+ this.onAddedMediaPlayout?.(mediaPlayout, this.context);
282
+ }
283
+ _onRemovedMediaPlayout(mediaPlayout) {
284
+ this.onRemovedMediaPlayout?.(mediaPlayout, this.context);
285
+ }
286
+ _onMediaSourceAdded(mediaSource) {
287
+ this.onMediaSourceAdded?.(mediaSource, this.context);
288
+ }
289
+ _onMediaSourceRemoved(mediaSource) {
290
+ this.onMediaSourceRemoved?.(mediaSource, this.context);
291
+ }
292
+ _onClientIssue(observedClent, issue) {
293
+ this.onClientIssue?.(observedClent, issue, this.context);
294
+ }
295
+ _onClientMetadata(observedClient, metadata) {
296
+ this.onClientMetadata?.(observedClient, metadata, this.context);
297
+ }
298
+ _onClientExtensionStats(observedClient, extensionStats) {
299
+ this.onClientExtensionStats?.(observedClient, extensionStats, this.context);
300
+ }
301
+ _onClientJoined(observedClient) {
302
+ this.onClientJoined?.(observedClient, this.context);
303
+ }
304
+ _onClientLeft(observedClient) {
305
+ this.onClientLeft?.(observedClient, this.context);
306
+ }
307
+ _onUserMediaError(observedClient, error) {
308
+ this.onClientUserMediaError?.(observedClient, error, this.context);
309
+ }
310
+ _onUsingTurn(observedClient, usingTurn) {
311
+ this.onClientUsingTurn?.(observedClient, usingTurn, this.context);
312
+ }
313
+ }
314
+ exports.ObservedCallEventMonitor = ObservedCallEventMonitor;