@observertc/observer-js 1.0.1-4daea92.0 → 1.0.1-5a1b94b.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.
- package/README.md +535 -1
- package/lib/ObservedCall.d.ts +18 -2
- package/lib/ObservedCall.d.ts.map +1 -1
- package/lib/ObservedCall.js +65 -11
- package/lib/ObservedCallEventMonitor.d.ts +14 -13
- package/lib/ObservedCallEventMonitor.d.ts.map +1 -1
- package/lib/ObservedCallEventMonitor.js +3 -1
- package/lib/ObservedClient.d.ts +9 -9
- package/lib/ObservedClient.d.ts.map +1 -1
- package/lib/ObservedClient.js +181 -15
- package/lib/ObservedClientEventMonitor.d.ts +54 -52
- package/lib/ObservedClientEventMonitor.d.ts.map +1 -1
- package/lib/ObservedClientEventMonitor.js +7 -0
- package/lib/ObservedTURN.d.ts +1 -1
- package/lib/ObservedTURN.d.ts.map +1 -1
- package/lib/ObservedTURN.js +1 -0
- package/lib/ObservedTurnServer.d.ts +2 -2
- package/lib/ObservedTurnServer.d.ts.map +1 -1
- package/lib/Observer.d.ts +6 -5
- package/lib/Observer.d.ts.map +1 -1
- package/lib/Observer.js +13 -20
- package/lib/ObserverEventMonitor.d.ts +45 -13
- package/lib/ObserverEventMonitor.d.ts.map +1 -1
- package/lib/ObserverEventMonitor.js +114 -1
- package/lib/common/ObserverSummary.d.ts.map +1 -0
- package/lib/common/types.d.ts +20 -0
- package/lib/common/types.d.ts.map +1 -1
- package/lib/index.d.ts +17 -17
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +16 -16
- package/lib/mediasoup/ObservedMediasoupRouter.d.ts +7 -0
- package/lib/mediasoup/ObservedMediasoupRouter.d.ts.map +1 -0
- package/lib/mediasoup/ObservedMediasoupRouter.js +12 -0
- package/lib/schema/ClientEventTypes.d.ts +147 -79
- package/lib/schema/ClientEventTypes.d.ts.map +1 -1
- package/lib/schema/ClientEventTypes.js +5 -2
- package/lib/schema/ClientSample.d.ts +1 -1
- package/lib/schema/ClientSample.d.ts.map +1 -1
- package/lib/updaters/OnAnyCallObserverUpdater.d.ts.map +1 -1
- package/lib/utils/MediasoupRemoteTrackResolver.d.ts +2 -2
- package/lib/utils/MediasoupRemoteTrackResolver.d.ts.map +1 -1
- package/lib/utils/RemoteTrackResolver.d.ts +2 -2
- package/lib/utils/RemoteTrackResolver.d.ts.map +1 -1
- package/lib/{ObservedCertificate.d.ts → webrtc/ObservedCertificate.d.ts} +1 -1
- package/lib/webrtc/ObservedCertificate.d.ts.map +1 -0
- package/lib/{ObservedCodec.d.ts → webrtc/ObservedCodec.d.ts} +1 -1
- package/lib/webrtc/ObservedCodec.d.ts.map +1 -0
- package/lib/{ObservedDataChannel.d.ts → webrtc/ObservedDataChannel.d.ts} +1 -1
- package/lib/webrtc/ObservedDataChannel.d.ts.map +1 -0
- package/lib/{ObservedIceCandidate.d.ts → webrtc/ObservedIceCandidate.d.ts} +1 -1
- package/lib/webrtc/ObservedIceCandidate.d.ts.map +1 -0
- package/lib/{ObservedIceCandidatePair.d.ts → webrtc/ObservedIceCandidatePair.d.ts} +3 -2
- package/lib/webrtc/ObservedIceCandidatePair.d.ts.map +1 -0
- package/lib/{ObservedIceCandidatePair.js → webrtc/ObservedIceCandidatePair.js} +17 -1
- package/lib/{ObservedIceTransport.d.ts → webrtc/ObservedIceTransport.d.ts} +1 -1
- package/lib/webrtc/ObservedIceTransport.d.ts.map +1 -0
- package/lib/{ObservedInboundRtp.d.ts → webrtc/ObservedInboundRtp.d.ts} +2 -2
- package/lib/webrtc/ObservedInboundRtp.d.ts.map +1 -0
- package/lib/{ObservedInboundTrack.d.ts → webrtc/ObservedInboundTrack.d.ts} +5 -4
- package/lib/webrtc/ObservedInboundTrack.d.ts.map +1 -0
- package/lib/{ObservedInboundTrack.js → webrtc/ObservedInboundTrack.js} +2 -1
- package/lib/{ObservedMediaPlayout.d.ts → webrtc/ObservedMediaPlayout.d.ts} +2 -2
- package/lib/webrtc/ObservedMediaPlayout.d.ts.map +1 -0
- package/lib/{ObservedMediaSource.d.ts → webrtc/ObservedMediaSource.d.ts} +2 -2
- package/lib/webrtc/ObservedMediaSource.d.ts.map +1 -0
- package/lib/{ObservedOutboundRtp.d.ts → webrtc/ObservedOutboundRtp.d.ts} +2 -2
- package/lib/webrtc/ObservedOutboundRtp.d.ts.map +1 -0
- package/lib/{ObservedOutboundTrack.d.ts → webrtc/ObservedOutboundTrack.d.ts} +5 -4
- package/lib/webrtc/ObservedOutboundTrack.d.ts.map +1 -0
- package/lib/{ObservedOutboundTrack.js → webrtc/ObservedOutboundTrack.js} +2 -1
- package/lib/{ObservedPeerConnection.d.ts → webrtc/ObservedPeerConnection.d.ts} +26 -4
- package/lib/webrtc/ObservedPeerConnection.d.ts.map +1 -0
- package/lib/{ObservedPeerConnection.js → webrtc/ObservedPeerConnection.js} +80 -17
- package/lib/{ObservedPeerConnectionTransport.d.ts → webrtc/ObservedPeerConnectionTransport.d.ts} +1 -1
- package/lib/webrtc/ObservedPeerConnectionTransport.d.ts.map +1 -0
- package/lib/{ObservedRemoteInboundRtp.d.ts → webrtc/ObservedRemoteInboundRtp.d.ts} +2 -2
- package/lib/webrtc/ObservedRemoteInboundRtp.d.ts.map +1 -0
- package/lib/{ObservedRemoteOutboundRtp.d.ts → webrtc/ObservedRemoteOutboundRtp.d.ts} +2 -2
- package/lib/webrtc/ObservedRemoteOutboundRtp.d.ts.map +1 -0
- package/package.json +1 -1
- package/src/ObservedCall.ts +70 -17
- package/src/ObservedCallEventMonitor.ts +17 -14
- package/src/ObservedClient.ts +195 -22
- package/src/ObservedClientEventMonitor.ts +59 -51
- package/src/ObservedTURN.ts +2 -1
- package/src/ObservedTurnServer.ts +2 -2
- package/src/Observer.ts +22 -27
- package/src/ObserverEventMonitor.ts +167 -14
- package/src/common/types.ts +20 -1
- package/src/index.ts +18 -19
- package/src/mediasoup/ObservedMediasoupRouter.ts +12 -0
- package/src/schema/ClientEventTypes.ts +187 -83
- package/src/schema/ClientSample.ts +1 -1
- package/src/updaters/OnAnyCallObserverUpdater.ts +1 -1
- package/src/utils/MediasoupRemoteTrackResolver.ts +2 -2
- package/src/utils/RemoteTrackResolver.ts +2 -2
- package/src/{ObservedCertificate.ts → webrtc/ObservedCertificate.ts} +1 -1
- package/src/{ObservedCodec.ts → webrtc/ObservedCodec.ts} +1 -1
- package/src/{ObservedDataChannel.ts → webrtc/ObservedDataChannel.ts} +1 -1
- package/src/{ObservedIceCandidate.ts → webrtc/ObservedIceCandidate.ts} +1 -1
- package/src/{ObservedIceCandidatePair.ts → webrtc/ObservedIceCandidatePair.ts} +19 -3
- package/src/{ObservedIceTransport.ts → webrtc/ObservedIceTransport.ts} +1 -1
- package/src/{ObservedInboundRtp.ts → webrtc/ObservedInboundRtp.ts} +2 -2
- package/src/{ObservedInboundTrack.ts → webrtc/ObservedInboundTrack.ts} +6 -4
- package/src/{ObservedMediaPlayout.ts → webrtc/ObservedMediaPlayout.ts} +2 -2
- package/src/{ObservedMediaSource.ts → webrtc/ObservedMediaSource.ts} +2 -2
- package/src/{ObservedOutboundRtp.ts → webrtc/ObservedOutboundRtp.ts} +2 -2
- package/src/{ObservedOutboundTrack.ts → webrtc/ObservedOutboundTrack.ts} +6 -4
- package/src/{ObservedPeerConnection.ts → webrtc/ObservedPeerConnection.ts} +122 -37
- package/src/{ObservedPeerConnectionTransport.ts → webrtc/ObservedPeerConnectionTransport.ts} +1 -1
- package/src/{ObservedRemoteInboundRtp.ts → webrtc/ObservedRemoteInboundRtp.ts} +2 -2
- package/src/{ObservedRemoteOutboundRtp.ts → webrtc/ObservedRemoteOutboundRtp.ts} +2 -2
- package/lib/ObservedCertificate.d.ts.map +0 -1
- package/lib/ObservedCodec.d.ts.map +0 -1
- package/lib/ObservedDataChannel.d.ts.map +0 -1
- package/lib/ObservedIceCandidate.d.ts.map +0 -1
- package/lib/ObservedIceCandidatePair.d.ts.map +0 -1
- package/lib/ObservedIceTransport.d.ts.map +0 -1
- package/lib/ObservedInboundRtp.d.ts.map +0 -1
- package/lib/ObservedInboundTrack.d.ts.map +0 -1
- package/lib/ObservedMediaPlayout.d.ts.map +0 -1
- package/lib/ObservedMediaSource.d.ts.map +0 -1
- package/lib/ObservedOutboundRtp.d.ts.map +0 -1
- package/lib/ObservedOutboundTrack.d.ts.map +0 -1
- package/lib/ObservedPeerConnection.d.ts.map +0 -1
- package/lib/ObservedPeerConnectionTransport.d.ts.map +0 -1
- package/lib/ObservedRemoteInboundRtp.d.ts.map +0 -1
- package/lib/ObservedRemoteOutboundRtp.d.ts.map +0 -1
- package/lib/ObserverSummary.d.ts.map +0 -1
- /package/lib/{ObserverSummary.d.ts → common/ObserverSummary.d.ts} +0 -0
- /package/lib/{ObserverSummary.js → common/ObserverSummary.js} +0 -0
- /package/lib/{ObservedCertificate.js → webrtc/ObservedCertificate.js} +0 -0
- /package/lib/{ObservedCodec.js → webrtc/ObservedCodec.js} +0 -0
- /package/lib/{ObservedDataChannel.js → webrtc/ObservedDataChannel.js} +0 -0
- /package/lib/{ObservedIceCandidate.js → webrtc/ObservedIceCandidate.js} +0 -0
- /package/lib/{ObservedIceTransport.js → webrtc/ObservedIceTransport.js} +0 -0
- /package/lib/{ObservedInboundRtp.js → webrtc/ObservedInboundRtp.js} +0 -0
- /package/lib/{ObservedMediaPlayout.js → webrtc/ObservedMediaPlayout.js} +0 -0
- /package/lib/{ObservedMediaSource.js → webrtc/ObservedMediaSource.js} +0 -0
- /package/lib/{ObservedOutboundRtp.js → webrtc/ObservedOutboundRtp.js} +0 -0
- /package/lib/{ObservedPeerConnectionTransport.js → webrtc/ObservedPeerConnectionTransport.js} +0 -0
- /package/lib/{ObservedRemoteInboundRtp.js → webrtc/ObservedRemoteInboundRtp.js} +0 -0
- /package/lib/{ObservedRemoteOutboundRtp.js → webrtc/ObservedRemoteOutboundRtp.js} +0 -0
- /package/src/{ObserverSummary.ts → common/ObserverSummary.ts} +0 -0
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import { ObservedCertificate } from './ObservedCertificate';
|
|
2
|
-
import { ObservedClient } from './ObservedClient';
|
|
3
|
-
import { ObservedCodec } from './ObservedCodec';
|
|
4
|
-
import { ObservedDataChannel } from './ObservedDataChannel';
|
|
5
|
-
import { ObservedIceCandidate } from './ObservedIceCandidate';
|
|
6
|
-
import { ObservedIceCandidatePair } from './ObservedIceCandidatePair';
|
|
7
|
-
import { ObservedIceTransport } from './ObservedIceTransport';
|
|
8
|
-
import { ObservedInboundRtp } from './ObservedInboundRtp';
|
|
9
|
-
import { ObservedInboundTrack } from './ObservedInboundTrack';
|
|
10
|
-
import { ObservedMediaPlayout } from './ObservedMediaPlayout';
|
|
11
|
-
import { ObservedMediaSource } from './ObservedMediaSource';
|
|
12
|
-
import { ObservedOutboundRtp } from './ObservedOutboundRtp';
|
|
13
|
-
import { ObservedOutboundTrack } from './ObservedOutboundTrack';
|
|
14
|
-
import { ObservedPeerConnection } from './ObservedPeerConnection';
|
|
1
|
+
import { ObservedCertificate } from './webrtc/ObservedCertificate';
|
|
2
|
+
import { ObservedClient, ObservedClientEvents } from './ObservedClient';
|
|
3
|
+
import { ObservedCodec } from './webrtc/ObservedCodec';
|
|
4
|
+
import { ObservedDataChannel } from './webrtc/ObservedDataChannel';
|
|
5
|
+
import { ObservedIceCandidate } from './webrtc/ObservedIceCandidate';
|
|
6
|
+
import { ObservedIceCandidatePair } from './webrtc/ObservedIceCandidatePair';
|
|
7
|
+
import { ObservedIceTransport } from './webrtc/ObservedIceTransport';
|
|
8
|
+
import { ObservedInboundRtp } from './webrtc/ObservedInboundRtp';
|
|
9
|
+
import { ObservedInboundTrack } from './webrtc/ObservedInboundTrack';
|
|
10
|
+
import { ObservedMediaPlayout } from './webrtc/ObservedMediaPlayout';
|
|
11
|
+
import { ObservedMediaSource } from './webrtc/ObservedMediaSource';
|
|
12
|
+
import { ObservedOutboundRtp } from './webrtc/ObservedOutboundRtp';
|
|
13
|
+
import { ObservedOutboundTrack } from './webrtc/ObservedOutboundTrack';
|
|
14
|
+
import { ObservedPeerConnection } from './webrtc/ObservedPeerConnection';
|
|
15
15
|
import { ClientIssue, ClientMetaData, ExtensionStat } from './schema/ClientSample';
|
|
16
16
|
|
|
17
|
-
export class ObservedClientEventMonitor<
|
|
17
|
+
export class ObservedClientEventMonitor<AppContext, ClientAppData extends Record<string, unknown> = Record<string, unknown>> {
|
|
18
18
|
public constructor(
|
|
19
|
-
public readonly observedClient: ObservedClient
|
|
20
|
-
public readonly context:
|
|
19
|
+
public readonly observedClient: ObservedClient<ClientAppData>,
|
|
20
|
+
public readonly context: AppContext,
|
|
21
21
|
) {
|
|
22
22
|
this._onPeerConnconnectionAdded = this._onPeerConnconnectionAdded.bind(this);
|
|
23
23
|
this._onPeerConnectionRemoved = this._onPeerConnectionRemoved.bind(this);
|
|
@@ -52,6 +52,8 @@ export class ObservedClientEventMonitor<Context> {
|
|
|
52
52
|
this._onClientLeft = this._onClientLeft.bind(this);
|
|
53
53
|
this._onUserMediaError = this._onUserMediaError.bind(this);
|
|
54
54
|
this._onUsingTurn = this._onUsingTurn.bind(this);
|
|
55
|
+
this._onClientUpdated = this._onClientUpdated.bind(this);
|
|
56
|
+
this._onClientExtensionStats = this._onClientExtensionStats.bind(this);
|
|
55
57
|
|
|
56
58
|
this.observedClient.on('newpeerconnection', this._onPeerConnconnectionAdded);
|
|
57
59
|
this.observedClient.on('issue', this._onClientIssue);
|
|
@@ -61,11 +63,17 @@ export class ObservedClientEventMonitor<Context> {
|
|
|
61
63
|
this.observedClient.on('rejoined', this._onClientJoined);
|
|
62
64
|
this.observedClient.on('usermediaerror', this._onUserMediaError);
|
|
63
65
|
this.observedClient.on('usingturn', this._onUsingTurn);
|
|
66
|
+
this.observedClient.on('update', this._onClientUpdated);
|
|
64
67
|
|
|
65
68
|
this.observedClient.once('close', this._onClientClosed);
|
|
66
69
|
}
|
|
67
70
|
|
|
68
|
-
public
|
|
71
|
+
public onClientUpdated?: (client: ObservedClient, event: ObservedClientEvents['update'][0], ctx: AppContext) => void;
|
|
72
|
+
private _onClientUpdated(...args: ObservedClientEvents['update']) {
|
|
73
|
+
this.onClientUpdated?.(this.observedClient, args[0], this.context);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
public onClientClosed?: (client: ObservedClient, ctx: AppContext) => void;
|
|
69
77
|
private _onClientClosed() {
|
|
70
78
|
this.onClientClosed?.(this.observedClient, this.context);
|
|
71
79
|
|
|
@@ -80,7 +88,7 @@ export class ObservedClientEventMonitor<Context> {
|
|
|
80
88
|
|
|
81
89
|
}
|
|
82
90
|
|
|
83
|
-
public onPeerConnectionAdded?: (peerConnection: ObservedPeerConnection, ctx:
|
|
91
|
+
public onPeerConnectionAdded?: (peerConnection: ObservedPeerConnection, ctx: AppContext) => void;
|
|
84
92
|
private _onPeerConnconnectionAdded(peerConnection: ObservedPeerConnection) {
|
|
85
93
|
this.onPeerConnectionAdded?.(peerConnection, this.context);
|
|
86
94
|
|
|
@@ -113,7 +121,7 @@ export class ObservedClientEventMonitor<Context> {
|
|
|
113
121
|
|
|
114
122
|
}
|
|
115
123
|
|
|
116
|
-
public onPeerConnectionRemoved?: (peerConnection: ObservedPeerConnection, ctx:
|
|
124
|
+
public onPeerConnectionRemoved?: (peerConnection: ObservedPeerConnection, ctx: AppContext) => void;
|
|
117
125
|
private _onPeerConnectionRemoved(peerConnection: ObservedPeerConnection) {
|
|
118
126
|
this.onPeerConnectionRemoved?.(peerConnection, this.context);
|
|
119
127
|
|
|
@@ -144,157 +152,157 @@ export class ObservedClientEventMonitor<Context> {
|
|
|
144
152
|
|
|
145
153
|
}
|
|
146
154
|
|
|
147
|
-
public onCertificateAdded?: (certificate: ObservedCertificate, ctx:
|
|
155
|
+
public onCertificateAdded?: (certificate: ObservedCertificate, ctx: AppContext) => void;
|
|
148
156
|
private _onCertificateAdded(certificate: ObservedCertificate) {
|
|
149
157
|
this.onCertificateAdded?.(certificate, this.context);
|
|
150
158
|
}
|
|
151
159
|
|
|
152
|
-
public onCertificateRemoved?: (certificate: ObservedCertificate, ctx:
|
|
160
|
+
public onCertificateRemoved?: (certificate: ObservedCertificate, ctx: AppContext) => void;
|
|
153
161
|
private _onCertificateRemoved(certificate: ObservedCertificate) {
|
|
154
162
|
this.onCertificateRemoved?.(certificate, this.context);
|
|
155
163
|
}
|
|
156
164
|
|
|
157
|
-
public onInboundTrackAdded?: (inboundTrack: ObservedInboundTrack, ctx:
|
|
165
|
+
public onInboundTrackAdded?: (inboundTrack: ObservedInboundTrack, ctx: AppContext) => void;
|
|
158
166
|
private _onInboundTrackAdded(inboundTrack: ObservedInboundTrack) {
|
|
159
167
|
this.onInboundTrackAdded?.(inboundTrack, this.context);
|
|
160
168
|
}
|
|
161
169
|
|
|
162
|
-
public onInboundTrackRemoved?: (inboundTrack: ObservedInboundTrack, ctx:
|
|
170
|
+
public onInboundTrackRemoved?: (inboundTrack: ObservedInboundTrack, ctx: AppContext) => void;
|
|
163
171
|
private _onInboundTrackRemoved(inboundTrack: ObservedInboundTrack) {
|
|
164
172
|
this.onInboundTrackRemoved?.(inboundTrack, this.context);
|
|
165
173
|
}
|
|
166
174
|
|
|
167
|
-
public onOutboundTrackAdded?: (outboundTrack: ObservedOutboundTrack, ctx:
|
|
175
|
+
public onOutboundTrackAdded?: (outboundTrack: ObservedOutboundTrack, ctx: AppContext) => void;
|
|
168
176
|
private _onOutboundTrackAdded(outboundTrack: ObservedOutboundTrack) {
|
|
169
177
|
this.onOutboundTrackAdded?.(outboundTrack, this.context);
|
|
170
178
|
}
|
|
171
179
|
|
|
172
|
-
public onOutboundTrackRemoved?: (outboundTrack: ObservedOutboundTrack, ctx:
|
|
180
|
+
public onOutboundTrackRemoved?: (outboundTrack: ObservedOutboundTrack, ctx: AppContext) => void;
|
|
173
181
|
private _onOutboundTrackRemoved(outboundTrack: ObservedOutboundTrack) {
|
|
174
182
|
this.onOutboundTrackRemoved?.(outboundTrack, this.context);
|
|
175
183
|
}
|
|
176
184
|
|
|
177
|
-
public onInboundRtpAdded?: (inboundRtp: ObservedInboundRtp, ctx:
|
|
185
|
+
public onInboundRtpAdded?: (inboundRtp: ObservedInboundRtp, ctx: AppContext) => void;
|
|
178
186
|
private _onInboundRtpAdded(inboundRtp: ObservedInboundRtp) {
|
|
179
187
|
this.onInboundRtpAdded?.(inboundRtp, this.context);
|
|
180
188
|
}
|
|
181
189
|
|
|
182
|
-
public onInboundRtpRemoved?: (inboundRtp: ObservedInboundRtp, ctx:
|
|
190
|
+
public onInboundRtpRemoved?: (inboundRtp: ObservedInboundRtp, ctx: AppContext) => void;
|
|
183
191
|
private _onInboundRtpRemoved(inboundRtp: ObservedInboundRtp) {
|
|
184
192
|
this.onInboundRtpRemoved?.(inboundRtp, this.context);
|
|
185
193
|
}
|
|
186
194
|
|
|
187
|
-
public onOutboundRtpAdded?: (outboundRtp: ObservedOutboundRtp, ctx:
|
|
195
|
+
public onOutboundRtpAdded?: (outboundRtp: ObservedOutboundRtp, ctx: AppContext) => void;
|
|
188
196
|
private _onOutboundRtpAdded(outboundRtp: ObservedOutboundRtp) {
|
|
189
197
|
this.onOutboundRtpAdded?.(outboundRtp, this.context);
|
|
190
198
|
}
|
|
191
199
|
|
|
192
|
-
public onOutboundRtpRemoved?: (outboundRtp: ObservedOutboundRtp, ctx:
|
|
200
|
+
public onOutboundRtpRemoved?: (outboundRtp: ObservedOutboundRtp, ctx: AppContext) => void;
|
|
193
201
|
private _onOutboundRtpRemoved(outboundRtp: ObservedOutboundRtp) {
|
|
194
202
|
this.onOutboundRtpRemoved?.(outboundRtp, this.context);
|
|
195
203
|
}
|
|
196
204
|
|
|
197
|
-
public onDataChannelAdded?: (dataChannel: ObservedDataChannel, ctx:
|
|
205
|
+
public onDataChannelAdded?: (dataChannel: ObservedDataChannel, ctx: AppContext) => void;
|
|
198
206
|
private _onDataChannelAdded(dataChannel: ObservedDataChannel) {
|
|
199
207
|
this.onDataChannelAdded?.(dataChannel, this.context);
|
|
200
208
|
}
|
|
201
209
|
|
|
202
|
-
public onDataChannelRemoved?: (dataChannel: ObservedDataChannel, ctx:
|
|
210
|
+
public onDataChannelRemoved?: (dataChannel: ObservedDataChannel, ctx: AppContext) => void;
|
|
203
211
|
private _onDataChannelRemoved(dataChannel: ObservedDataChannel) {
|
|
204
212
|
this.onDataChannelRemoved?.(dataChannel, this.context);
|
|
205
213
|
}
|
|
206
214
|
|
|
207
|
-
public onAddedIceTransport?: (iceTransport: ObservedIceTransport, ctx:
|
|
215
|
+
public onAddedIceTransport?: (iceTransport: ObservedIceTransport, ctx: AppContext) => void;
|
|
208
216
|
private _onAddedIceTransport(iceTransport: ObservedIceTransport) {
|
|
209
217
|
this.onAddedIceTransport?.(iceTransport, this.context);
|
|
210
218
|
}
|
|
211
219
|
|
|
212
|
-
public onRemovedIceTransport?: (iceTransport: ObservedIceTransport, ctx:
|
|
220
|
+
public onRemovedIceTransport?: (iceTransport: ObservedIceTransport, ctx: AppContext) => void;
|
|
213
221
|
private _onRemovedIceTransport(iceTransport: ObservedIceTransport) {
|
|
214
222
|
this.onRemovedIceTransport?.(iceTransport, this.context);
|
|
215
223
|
}
|
|
216
224
|
|
|
217
|
-
public onIceCandidateAdded?: (iceCandidate: ObservedIceCandidate, ctx:
|
|
225
|
+
public onIceCandidateAdded?: (iceCandidate: ObservedIceCandidate, ctx: AppContext) => void;
|
|
218
226
|
private _onIceCandidateAdded(iceCandidate: ObservedIceCandidate) {
|
|
219
227
|
this.onIceCandidateAdded?.(iceCandidate, this.context);
|
|
220
228
|
}
|
|
221
229
|
|
|
222
|
-
public onIceCandidateRemoved?: (iceCandidate: ObservedIceCandidate, ctx:
|
|
230
|
+
public onIceCandidateRemoved?: (iceCandidate: ObservedIceCandidate, ctx: AppContext) => void;
|
|
223
231
|
private _onIceCandidateRemoved(iceCandidate: ObservedIceCandidate) {
|
|
224
232
|
this.onIceCandidateRemoved?.(iceCandidate, this.context);
|
|
225
233
|
}
|
|
226
234
|
|
|
227
|
-
public onAddedIceCandidatePair?: (candidatePair: ObservedIceCandidatePair, ctx:
|
|
235
|
+
public onAddedIceCandidatePair?: (candidatePair: ObservedIceCandidatePair, ctx: AppContext) => void;
|
|
228
236
|
private _onAddedIceCandidatePair(candidatePair: ObservedIceCandidatePair) {
|
|
229
237
|
this.onAddedIceCandidatePair?.(candidatePair, this.context);
|
|
230
238
|
}
|
|
231
239
|
|
|
232
|
-
public onRemovedIceCandidatePair?: (candidatePair: ObservedIceCandidatePair, ctx:
|
|
240
|
+
public onRemovedIceCandidatePair?: (candidatePair: ObservedIceCandidatePair, ctx: AppContext) => void;
|
|
233
241
|
private _onRemovedIceCandidatePair(candidatePair: ObservedIceCandidatePair) {
|
|
234
242
|
this.onRemovedIceCandidatePair?.(candidatePair, this.context);
|
|
235
243
|
}
|
|
236
244
|
|
|
237
|
-
public onAddedMediaCodec?: (codec: ObservedCodec, ctx:
|
|
245
|
+
public onAddedMediaCodec?: (codec: ObservedCodec, ctx: AppContext) => void;
|
|
238
246
|
private _onAddedMediaCodec(codec: ObservedCodec) {
|
|
239
247
|
this.onAddedMediaCodec?.(codec, this.context);
|
|
240
248
|
}
|
|
241
249
|
|
|
242
|
-
public onRemovedMediaCodec?: (codec: ObservedCodec, ctx:
|
|
250
|
+
public onRemovedMediaCodec?: (codec: ObservedCodec, ctx: AppContext) => void;
|
|
243
251
|
private _onRemovedMediaCodec(codec: ObservedCodec) {
|
|
244
252
|
this.onRemovedMediaCodec?.(codec, this.context);
|
|
245
253
|
}
|
|
246
254
|
|
|
247
|
-
public onAddedMediaPlayout?: (mediaPlayout: ObservedMediaPlayout, ctx:
|
|
255
|
+
public onAddedMediaPlayout?: (mediaPlayout: ObservedMediaPlayout, ctx: AppContext) => void;
|
|
248
256
|
private _onAddedMediaPlayout(mediaPlayout: ObservedMediaPlayout) {
|
|
249
257
|
this.onAddedMediaPlayout?.(mediaPlayout, this.context);
|
|
250
258
|
}
|
|
251
259
|
|
|
252
|
-
public onRemovedMediaPlayout?: (mediaPlayout: ObservedMediaPlayout, ctx:
|
|
260
|
+
public onRemovedMediaPlayout?: (mediaPlayout: ObservedMediaPlayout, ctx: AppContext) => void;
|
|
253
261
|
private _onRemovedMediaPlayout(mediaPlayout: ObservedMediaPlayout) {
|
|
254
262
|
this.onRemovedMediaPlayout?.(mediaPlayout, this.context);
|
|
255
263
|
}
|
|
256
264
|
|
|
257
|
-
public onMediaSourceAdded?: (mediaSource: ObservedMediaSource, ctx:
|
|
265
|
+
public onMediaSourceAdded?: (mediaSource: ObservedMediaSource, ctx: AppContext) => void;
|
|
258
266
|
private _onMediaSourceAdded(mediaSource: ObservedMediaSource) {
|
|
259
267
|
this.onMediaSourceAdded?.(mediaSource, this.context);
|
|
260
268
|
}
|
|
261
269
|
|
|
262
|
-
public onMediaSourceRemoved?: (mediaSource: ObservedMediaSource, ctx:
|
|
270
|
+
public onMediaSourceRemoved?: (mediaSource: ObservedMediaSource, ctx: AppContext) => void;
|
|
263
271
|
private _onMediaSourceRemoved(mediaSource: ObservedMediaSource) {
|
|
264
272
|
this.onMediaSourceRemoved?.(mediaSource, this.context);
|
|
265
273
|
}
|
|
266
274
|
|
|
267
|
-
public onClientIssue?: (issue: ClientIssue, ctx:
|
|
275
|
+
public onClientIssue?: (issue: ClientIssue, ctx: AppContext) => void;
|
|
268
276
|
private _onClientIssue(issue: ClientIssue) {
|
|
269
277
|
this.onClientIssue?.(issue, this.context);
|
|
270
278
|
}
|
|
271
279
|
|
|
272
|
-
public onClientMetadata?: (metadata: ClientMetaData, ctx:
|
|
280
|
+
public onClientMetadata?: (metadata: ClientMetaData, ctx: AppContext) => void;
|
|
273
281
|
private _onClientMetadata(metadata: ClientMetaData) {
|
|
274
282
|
this.onClientMetadata?.(metadata, this.context);
|
|
275
283
|
}
|
|
276
284
|
|
|
277
|
-
public onClientExtensionStats?: (extensionStats: ExtensionStat, ctx:
|
|
285
|
+
public onClientExtensionStats?: (extensionStats: ExtensionStat, ctx: AppContext) => void;
|
|
278
286
|
private _onClientExtensionStats(extensionStats: ExtensionStat) {
|
|
279
287
|
this.onClientExtensionStats?.(extensionStats, this.context);
|
|
280
288
|
}
|
|
281
289
|
|
|
282
|
-
public onClientJoined?: (client: ObservedClient, ctx:
|
|
290
|
+
public onClientJoined?: (client: ObservedClient, ctx: AppContext) => void;
|
|
283
291
|
private _onClientJoined() {
|
|
284
292
|
this.onClientJoined?.(this.observedClient, this.context);
|
|
285
293
|
}
|
|
286
294
|
|
|
287
|
-
public onClientLeft?: (client: ObservedClient, ctx:
|
|
295
|
+
public onClientLeft?: (client: ObservedClient, ctx: AppContext) => void;
|
|
288
296
|
private _onClientLeft() {
|
|
289
297
|
this.onClientLeft?.(this.observedClient, this.context);
|
|
290
298
|
}
|
|
291
299
|
|
|
292
|
-
public onUserMediaError?: (error: string, observedClient: ObservedClient, ctx:
|
|
300
|
+
public onUserMediaError?: (error: string, observedClient: ObservedClient, ctx: AppContext) => void;
|
|
293
301
|
private _onUserMediaError(error: string) {
|
|
294
302
|
this.onUserMediaError?.(error, this.observedClient, this.context);
|
|
295
303
|
}
|
|
296
304
|
|
|
297
|
-
public onUsingTurn?: (client: ObservedClient, ctx:
|
|
305
|
+
public onUsingTurn?: (client: ObservedClient, ctx: AppContext) => void;
|
|
298
306
|
private _onUsingTurn() {
|
|
299
307
|
this.onUsingTurn?.(this.observedClient, this.context);
|
|
300
308
|
}
|
package/src/ObservedTURN.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { EventEmitter } from 'stream';
|
|
2
|
-
import { ObservedPeerConnection } from './ObservedPeerConnection';
|
|
2
|
+
import { ObservedPeerConnection } from './webrtc/ObservedPeerConnection';
|
|
3
3
|
import { ObservedTurnServer } from './ObservedTurnServer';
|
|
4
4
|
import { createLogger } from './common/logger';
|
|
5
5
|
|
|
@@ -34,6 +34,7 @@ export class ObservedTURN extends EventEmitter {
|
|
|
34
34
|
public constructor(
|
|
35
35
|
) {
|
|
36
36
|
super();
|
|
37
|
+
this.setMaxListeners(Infinity);
|
|
37
38
|
}
|
|
38
39
|
|
|
39
40
|
public update() {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ObservedIceCandidatePair } from './ObservedIceCandidatePair';
|
|
2
|
-
import { ObservedPeerConnection } from './ObservedPeerConnection';
|
|
1
|
+
import { ObservedIceCandidatePair } from './webrtc/ObservedIceCandidatePair';
|
|
2
|
+
import { ObservedPeerConnection } from './webrtc/ObservedPeerConnection';
|
|
3
3
|
import { ObservedTURN } from './ObservedTURN';
|
|
4
4
|
|
|
5
5
|
export class ObservedTurnServer {
|
package/src/Observer.ts
CHANGED
|
@@ -17,19 +17,20 @@ const logger = createLogger('Observer');
|
|
|
17
17
|
export type ObserverEvents = {
|
|
18
18
|
'client-event': [ObservedClient, ClientEvent];
|
|
19
19
|
'call-updated': [ObservedCall],
|
|
20
|
-
'client-issue': [ObservedClient, ClientIssue]
|
|
21
|
-
'client-metadata': [ObservedClient, ClientMetaData]
|
|
22
|
-
'client-extension-stats': [ObservedClient, ExtensionStat]
|
|
20
|
+
'client-issue': [ObservedClient, ClientIssue];
|
|
21
|
+
'client-metadata': [ObservedClient, ClientMetaData];
|
|
22
|
+
'client-extension-stats': [ObservedClient, ExtensionStat];
|
|
23
23
|
'newcall': [ObservedCall],
|
|
24
24
|
'update': [],
|
|
25
25
|
'close': [],
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
export type ObserverConfig = {
|
|
28
|
+
export type ObserverConfig<AppData extends Record<string, unknown> = Record<string, unknown>> = {
|
|
29
29
|
updatePolicy?: 'update-on-any-call-updated' | 'update-when-all-call-updated' | 'update-on-interval',
|
|
30
30
|
updateIntervalInMs?: number,
|
|
31
31
|
defaultCallUpdatePolicy?: ObservedCallSettings['updatePolicy'],
|
|
32
32
|
defaultCallUpdateIntervalInMs?: number,
|
|
33
|
+
appData?: AppData,
|
|
33
34
|
}
|
|
34
35
|
|
|
35
36
|
export declare interface Observer {
|
|
@@ -39,7 +40,7 @@ export declare interface Observer {
|
|
|
39
40
|
emit<U extends keyof ObserverEvents>(event: U, ...args: ObserverEvents[U]): boolean;
|
|
40
41
|
}
|
|
41
42
|
|
|
42
|
-
export class Observer extends EventEmitter {
|
|
43
|
+
export class Observer<AppData extends Record<string, unknown> = Record<string, unknown>> extends EventEmitter {
|
|
43
44
|
public readonly detectors: Detectors;
|
|
44
45
|
|
|
45
46
|
public readonly observedTURN = new ObservedTURN();
|
|
@@ -67,49 +68,45 @@ export class Observer extends EventEmitter {
|
|
|
67
68
|
return this.observedCalls.size;
|
|
68
69
|
}
|
|
69
70
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
public constructor(public readonly config: ObserverConfig = {
|
|
71
|
+
public constructor(public readonly config: ObserverConfig<AppData> = {
|
|
73
72
|
updatePolicy: 'update-when-all-call-updated',
|
|
74
73
|
updateIntervalInMs: undefined,
|
|
74
|
+
appData: {} as AppData,
|
|
75
75
|
}) {
|
|
76
76
|
super();
|
|
77
77
|
this.setMaxListeners(Infinity);
|
|
78
78
|
this.update = this.update.bind(this);
|
|
79
79
|
|
|
80
|
-
|
|
81
|
-
if (this.config.updatePolicy && this.config.updatePolicy !== 'update-on-interval') {
|
|
82
|
-
throw new Error('update policy must be update-on-interval if updateIntervalInMs is set in config');
|
|
83
|
-
}
|
|
84
|
-
this._timer = setInterval(this.update.bind(this), this.config.updateIntervalInMs);
|
|
85
|
-
}
|
|
80
|
+
const currentUpdatePolicy = (config?.updatePolicy) ?? 'update-when-all-call-updated';
|
|
86
81
|
|
|
87
|
-
|
|
88
|
-
if (this.config.updatePolicy !== 'update-on-interval') {
|
|
89
|
-
throw new Error('updatePolicy must be update-on-interval if updateIntervalInMs is set in config');
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
switch (this.config.updatePolicy) {
|
|
82
|
+
switch (currentUpdatePolicy) {
|
|
93
83
|
case 'update-on-any-call-updated':
|
|
94
|
-
this.updater = new
|
|
84
|
+
this.updater = new OnAnyCallObserverUpdater(this);
|
|
95
85
|
break;
|
|
96
86
|
case 'update-when-all-call-updated':
|
|
97
|
-
this.updater = new
|
|
87
|
+
this.updater = new OnAllCallObserverUpdater(this);
|
|
98
88
|
break;
|
|
99
|
-
case 'update-on-interval':
|
|
100
|
-
|
|
89
|
+
case 'update-on-interval': {
|
|
90
|
+
const interval = config?.updateIntervalInMs;
|
|
91
|
+
|
|
92
|
+
if (!interval) {
|
|
101
93
|
throw new Error('updateIntervalInMs setting in config must be set if updatePolicy is update-on-interval');
|
|
102
94
|
}
|
|
103
95
|
this.updater = new OnIntervalUpdater(
|
|
104
|
-
|
|
96
|
+
interval,
|
|
105
97
|
this.update.bind(this),
|
|
106
98
|
);
|
|
107
99
|
break;
|
|
100
|
+
}
|
|
108
101
|
}
|
|
109
102
|
|
|
110
103
|
this.detectors = new Detectors();
|
|
111
104
|
}
|
|
112
105
|
|
|
106
|
+
public get appData() {
|
|
107
|
+
return this.config.appData;
|
|
108
|
+
}
|
|
109
|
+
|
|
113
110
|
public getObservedCall<T extends Record<string, unknown> = Record<string, unknown>>(callId: string): ObservedCall<T> | undefined {
|
|
114
111
|
if (this.closed || !this.observedCalls.has(callId)) return;
|
|
115
112
|
|
|
@@ -155,8 +152,6 @@ export class Observer extends EventEmitter {
|
|
|
155
152
|
return logger.debug('Attempted to close twice');
|
|
156
153
|
}
|
|
157
154
|
this.closed = true;
|
|
158
|
-
clearInterval(this._timer);
|
|
159
|
-
this._timer = undefined;
|
|
160
155
|
|
|
161
156
|
this.observedCalls.forEach((call) => call.close());
|
|
162
157
|
|