@observertc/observer-js 1.0.1-797e5af.0 → 1.0.1-9341fcd.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/lib/ObservedCall.d.ts +2 -0
- package/lib/ObservedCall.d.ts.map +1 -1
- package/lib/ObservedCall.js +4 -0
- package/lib/ObservedCallEventMonitor.d.ts +104 -0
- package/lib/ObservedCallEventMonitor.d.ts.map +1 -0
- package/lib/ObservedCallEventMonitor.js +314 -0
- package/lib/ObservedClient.d.ts +2 -2
- package/lib/ObservedClient.d.ts.map +1 -1
- package/lib/ObservedClient.js +2 -4
- package/lib/ObservedIceCandidatePair.d.ts +2 -1
- package/lib/ObservedIceCandidatePair.d.ts.map +1 -1
- package/lib/ObservedIceCandidatePair.js +17 -1
- package/lib/Observer.d.ts +8 -4
- package/lib/Observer.d.ts.map +1 -1
- package/lib/Observer.js +14 -2
- package/lib/ObserverEventMonitor.d.ts +106 -0
- package/lib/ObserverEventMonitor.d.ts.map +1 -0
- package/lib/ObserverEventMonitor.js +320 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +3 -1
- package/lib/schema/ClientEventTypes.d.ts +17 -0
- package/lib/schema/ClientEventTypes.d.ts.map +1 -1
- package/lib/schema/ClientSample.d.ts +1 -1
- package/lib/schema/ClientSample.d.ts.map +1 -1
- package/lib/updaters/{OnAllCallObserverUpdater_.d.ts → OnAllCallObserverUpdater.d.ts} +3 -1
- package/lib/updaters/OnAllCallObserverUpdater.d.ts.map +1 -0
- package/lib/updaters/{OnAllCallObserverUpdater_.js → OnAllCallObserverUpdater.js} +13 -1
- package/lib/updaters/OnAllClientCallUpdater.d.ts +2 -0
- package/lib/updaters/OnAllClientCallUpdater.d.ts.map +1 -1
- package/lib/updaters/OnAllClientCallUpdater.js +16 -0
- package/lib/updaters/{OnAnyCallObserverUpdater_.d.ts → OnAnyCallObserverUpdater.d.ts} +2 -1
- package/lib/updaters/OnAnyCallObserverUpdater.d.ts.map +1 -0
- package/lib/updaters/{OnAnyCallObserverUpdater_.js → OnAnyCallObserverUpdater.js} +11 -1
- package/lib/updaters/OnAnyClientCallUpdater.d.ts +1 -0
- package/lib/updaters/OnAnyClientCallUpdater.d.ts.map +1 -1
- package/lib/updaters/OnAnyClientCallUpdater.js +11 -2
- package/lib/utils/MediasoupRemoteTrackResolver.d.ts +25 -0
- package/lib/utils/MediasoupRemoteTrackResolver.d.ts.map +1 -0
- package/lib/utils/MediasoupRemoteTrackResolver.js +110 -0
- package/package.json +1 -1
- package/src/ObservedCall.ts +5 -0
- package/src/ObservedCallEventMonitor.ts +392 -0
- package/src/ObservedClient.ts +4 -7
- package/src/ObservedIceCandidatePair.ts +18 -2
- package/src/Observer.ts +21 -6
- package/src/ObserverEventMonitor.ts +398 -0
- package/src/index.ts +1 -0
- package/src/schema/ClientEventTypes.ts +18 -0
- package/src/schema/ClientSample.ts +1 -1
- package/src/updaters/{OnAllCallObserverUpdater_.ts → OnAllCallObserverUpdater.ts} +14 -1
- package/src/updaters/OnAllClientCallUpdater.ts +15 -0
- package/src/updaters/{OnAnyCallObserverUpdater_.ts → OnAnyCallObserverUpdater.ts} +11 -2
- package/src/updaters/OnAnyClientCallUpdater.ts +9 -2
- package/src/utils/MediasoupRemoteTrackResolver.ts +155 -0
- package/lib/updaters/OnAllCallObserverUpdater_.d.ts.map +0 -1
- package/lib/updaters/OnAnyCallObserverUpdater_.d.ts.map +0 -1
|
@@ -0,0 +1,398 @@
|
|
|
1
|
+
import { ObservedCall } from './ObservedCall';
|
|
2
|
+
import { ObservedCertificate } from './ObservedCertificate';
|
|
3
|
+
import { ObservedClient, ObservedClientEvents } 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 { Observer } from './Observer';
|
|
17
|
+
import { ClientEvent, ClientIssue, ClientMetaData, ClientSample, ExtensionStat } from './schema/ClientSample';
|
|
18
|
+
|
|
19
|
+
export class ObserverEventMonitor<Context> {
|
|
20
|
+
public constructor(
|
|
21
|
+
public readonly observer: Observer,
|
|
22
|
+
public readonly context: Context,
|
|
23
|
+
) {
|
|
24
|
+
this._onPeerConnconnectionAdded = this._onPeerConnconnectionAdded.bind(this);
|
|
25
|
+
this._onPeerConnectionRemoved = this._onPeerConnectionRemoved.bind(this);
|
|
26
|
+
this._onCertificateAdded = this._onCertificateAdded.bind(this);
|
|
27
|
+
this._onCertificateRemoved = this._onCertificateRemoved.bind(this);
|
|
28
|
+
this._onInboundTrackAdded = this._onInboundTrackAdded.bind(this);
|
|
29
|
+
this._onInboundTrackRemoved = this._onInboundTrackRemoved.bind(this);
|
|
30
|
+
this._onOutboundTrackAdded = this._onOutboundTrackAdded.bind(this);
|
|
31
|
+
this._onOutboundTrackRemoved = this._onOutboundTrackRemoved.bind(this);
|
|
32
|
+
this._onInboundRtpAdded = this._onInboundRtpAdded.bind(this);
|
|
33
|
+
this._onInboundRtpRemoved = this._onInboundRtpRemoved.bind(this);
|
|
34
|
+
this._onOutboundRtpAdded = this._onOutboundRtpAdded.bind(this);
|
|
35
|
+
this._onOutboundRtpRemoved = this._onOutboundRtpRemoved.bind(this);
|
|
36
|
+
this._onDataChannelAdded = this._onDataChannelAdded.bind(this);
|
|
37
|
+
this._onDataChannelRemoved = this._onDataChannelRemoved.bind(this);
|
|
38
|
+
this._onAddedIceTransport = this._onAddedIceTransport.bind(this);
|
|
39
|
+
this._onRemovedIceTransport = this._onRemovedIceTransport.bind(this);
|
|
40
|
+
this._onIceCandidateAdded = this._onIceCandidateAdded.bind(this);
|
|
41
|
+
this._onIceCandidateRemoved = this._onIceCandidateRemoved.bind(this);
|
|
42
|
+
this._onAddedIceCandidatePair = this._onAddedIceCandidatePair.bind(this);
|
|
43
|
+
this._onRemovedIceCandidatePair = this._onRemovedIceCandidatePair.bind(this);
|
|
44
|
+
this._onAddedMediaCodec = this._onAddedMediaCodec.bind(this);
|
|
45
|
+
this._onRemovedMediaCodec = this._onRemovedMediaCodec.bind(this);
|
|
46
|
+
this._onAddedMediaPlayout = this._onAddedMediaPlayout.bind(this);
|
|
47
|
+
this._onRemovedMediaPlayout = this._onRemovedMediaPlayout.bind(this);
|
|
48
|
+
this._onMediaSourceAdded = this._onMediaSourceAdded.bind(this);
|
|
49
|
+
this._onMediaSourceRemoved = this._onMediaSourceRemoved.bind(this);
|
|
50
|
+
this._onClientIssue = this._onClientIssue.bind(this);
|
|
51
|
+
this._onClientMetadata = this._onClientMetadata.bind(this);
|
|
52
|
+
this._onClientJoined = this._onClientJoined.bind(this);
|
|
53
|
+
this._onClientLeft = this._onClientLeft.bind(this);
|
|
54
|
+
this._onUserMediaError = this._onUserMediaError.bind(this);
|
|
55
|
+
this._onUsingTurn = this._onUsingTurn.bind(this);
|
|
56
|
+
this._onClientAdded = this._onClientAdded.bind(this);
|
|
57
|
+
this._onCallAdded = this._onCallAdded.bind(this);
|
|
58
|
+
this._onClientRejoined = this._onClientRejoined.bind(this);
|
|
59
|
+
this._onClientExtensionStats = this._onClientExtensionStats.bind(this);
|
|
60
|
+
|
|
61
|
+
this.observer.once('close', () => {
|
|
62
|
+
this.observer.off('newcall', this._onCallAdded);
|
|
63
|
+
});
|
|
64
|
+
this.observer.on('newcall', this._onCallAdded);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// Public event handlers
|
|
68
|
+
public onCallAdded?: (call: ObservedCall, ctx: Context) => void;
|
|
69
|
+
public onCallRemoved?: (call: ObservedCall, ctx: Context) => void;
|
|
70
|
+
public onCallEmpty?: (call: ObservedCall, ctx: Context) => void;
|
|
71
|
+
public onCallNotEmpty?: (call: ObservedCall, ctx: Context) => void;
|
|
72
|
+
public onCallUpdated?: (call: ObservedCall, ctx: Context) => void;
|
|
73
|
+
|
|
74
|
+
public onClientAdded?: (client: ObservedClient, ctx: Context) => void;
|
|
75
|
+
public onClientClosed?: (client: ObservedClient, ctx: Context) => void;
|
|
76
|
+
public onClientRejoined?: (client: ObservedClient, ctx: Context) => void;
|
|
77
|
+
public onClientIssue?: (observedClent: ObservedClient, issue: ClientIssue, ctx: Context) => void;
|
|
78
|
+
public onClientMetadata?: (observedClient: ObservedClient, metadata: ClientMetaData, ctx: Context) => void;
|
|
79
|
+
public onClientExtensionStats?: (observedClient: ObservedClient, extensionStats: ExtensionStat, ctx: Context) => void;
|
|
80
|
+
public onClientJoined?: (client: ObservedClient, ctx: Context) => void;
|
|
81
|
+
public onClientLeft?: (client: ObservedClient, ctx: Context) => void;
|
|
82
|
+
public onClientUserMediaError?: (observedClient: ObservedClient, error: string, ctx: Context) => void;
|
|
83
|
+
public onClientUsingTurn?: (client: ObservedClient, usingTurn: boolean, ctx: Context) => void;
|
|
84
|
+
public onClientUpdated?: (client: ObservedClient, sample: ClientSample, ctx: Context) => void;
|
|
85
|
+
public onClientEvent?: (client: ObservedClient, event: ClientEvent, ctx: Context) => void;
|
|
86
|
+
|
|
87
|
+
public onPeerConnectionAdded?: (peerConnection: ObservedPeerConnection, ctx: Context) => void;
|
|
88
|
+
public onPeerConnectionRemoved?: (peerConnection: ObservedPeerConnection, ctx: Context) => void;
|
|
89
|
+
public onSelectedCandidatePairChanged?: (peerConnection: ObservedPeerConnection, ctx: Context) => void;
|
|
90
|
+
public onIceGatheringStateChange?: (peerConnection: ObservedPeerConnection, ctx: Context) => void;
|
|
91
|
+
public onIceConnectionStateChange?: (peerConnection: ObservedPeerConnection, ctx: Context) => void;
|
|
92
|
+
public onConnectionStateChange?: (peerConnection: ObservedPeerConnection, ctx: Context) => void;
|
|
93
|
+
|
|
94
|
+
public onCertificateAdded?: (certificate: ObservedCertificate, ctx: Context) => void;
|
|
95
|
+
public onCertificateRemoved?: (certificate: ObservedCertificate, ctx: Context) => void;
|
|
96
|
+
|
|
97
|
+
public onInboundTrackAdded?: (inboundTrack: ObservedInboundTrack, ctx: Context) => void;
|
|
98
|
+
public onInboundTrackRemoved?: (inboundTrack: ObservedInboundTrack, ctx: Context) => void;
|
|
99
|
+
|
|
100
|
+
public onOutboundTrackAdded?: (outboundTrack: ObservedOutboundTrack, ctx: Context) => void;
|
|
101
|
+
public onOutboundTrackRemoved?: (outboundTrack: ObservedOutboundTrack, ctx: Context) => void;
|
|
102
|
+
|
|
103
|
+
public onInboundRtpAdded?: (inboundRtp: ObservedInboundRtp, ctx: Context) => void;
|
|
104
|
+
public onInboundRtpRemoved?: (inboundRtp: ObservedInboundRtp, ctx: Context) => void;
|
|
105
|
+
|
|
106
|
+
public onOutboundRtpAdded?: (outboundRtp: ObservedOutboundRtp, ctx: Context) => void;
|
|
107
|
+
public onOutboundRtpRemoved?: (outboundRtp: ObservedOutboundRtp, ctx: Context) => void;
|
|
108
|
+
|
|
109
|
+
public onDataChannelAdded?: (dataChannel: ObservedDataChannel, ctx: Context) => void;
|
|
110
|
+
public onDataChannelRemoved?: (dataChannel: ObservedDataChannel, ctx: Context) => void;
|
|
111
|
+
|
|
112
|
+
public onAddedIceTransport?: (iceTransport: ObservedIceTransport, ctx: Context) => void;
|
|
113
|
+
public onRemovedIceTransport?: (iceTransport: ObservedIceTransport, ctx: Context) => void;
|
|
114
|
+
|
|
115
|
+
public onIceCandidateAdded?: (iceCandidate: ObservedIceCandidate, ctx: Context) => void;
|
|
116
|
+
public onIceCandidateRemoved?: (iceCandidate: ObservedIceCandidate, ctx: Context) => void;
|
|
117
|
+
|
|
118
|
+
public onAddedIceCandidatePair?: (candidatePair: ObservedIceCandidatePair, ctx: Context) => void;
|
|
119
|
+
public onRemovedIceCandidatePair?: (candidatePair: ObservedIceCandidatePair, ctx: Context) => void;
|
|
120
|
+
|
|
121
|
+
public onAddedMediaCodec?: (codec: ObservedCodec, ctx: Context) => void;
|
|
122
|
+
public onRemovedMediaCodec?: (codec: ObservedCodec, ctx: Context) => void;
|
|
123
|
+
|
|
124
|
+
public onAddedMediaPlayout?: (mediaPlayout: ObservedMediaPlayout, ctx: Context) => void;
|
|
125
|
+
public onRemovedMediaPlayout?: (mediaPlayout: ObservedMediaPlayout, ctx: Context) => void;
|
|
126
|
+
|
|
127
|
+
public onMediaSourceAdded?: (mediaSource: ObservedMediaSource, ctx: Context) => void;
|
|
128
|
+
public onMediaSourceRemoved?: (mediaSource: ObservedMediaSource, ctx: Context) => void;
|
|
129
|
+
|
|
130
|
+
private _onCallAdded(call: ObservedCall) {
|
|
131
|
+
const onCallEmpty = () => this.onCallEmpty?.(call, this.context);
|
|
132
|
+
const onCallNotEmpty = () => this.onCallNotEmpty?.(call, this.context);
|
|
133
|
+
const onCallUpdated = () => this.onCallUpdated?.(call, this.context);
|
|
134
|
+
|
|
135
|
+
call.once('close', () => {
|
|
136
|
+
call.off('newclient', this._onClientAdded);
|
|
137
|
+
call.off('empty', onCallEmpty);
|
|
138
|
+
call.off('not-empty', onCallNotEmpty);
|
|
139
|
+
call.off('update', onCallUpdated);
|
|
140
|
+
|
|
141
|
+
this.onCallRemoved?.(call, this.context);
|
|
142
|
+
});
|
|
143
|
+
call.on('newclient', this._onClientAdded);
|
|
144
|
+
call.on('empty', onCallEmpty);
|
|
145
|
+
call.on('not-empty', onCallNotEmpty);
|
|
146
|
+
call.on('update', onCallUpdated);
|
|
147
|
+
|
|
148
|
+
this.onCallAdded?.(call, this.context);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
private _onClientAdded(observedClient: ObservedClient) {
|
|
152
|
+
const onClientIssue = (issue: ClientIssue) => this._onClientIssue(observedClient, issue);
|
|
153
|
+
const onClientMetadata = (metaData: ClientMetaData) => this._onClientMetadata(observedClient, metaData);
|
|
154
|
+
const onClientJoined = () => this._onClientJoined(observedClient);
|
|
155
|
+
const onClientLeft = () => this._onClientLeft(observedClient);
|
|
156
|
+
const onClientRejoined = () => this._onClientRejoined(observedClient);
|
|
157
|
+
const onClientExtensionStats = (extensionStats: ExtensionStat) => this._onClientExtensionStats(observedClient, extensionStats);
|
|
158
|
+
const onUsingTurn = (usingTurn: boolean) => this._onUsingTurn(observedClient, usingTurn);
|
|
159
|
+
const onUserMediaError = (error: string) => this._onUserMediaError(observedClient, error);
|
|
160
|
+
const onClientUpdated = (...args: ObservedClientEvents['update']) => this.onClientUpdated?.(observedClient, args[0].sample, this.context);
|
|
161
|
+
const onClientEvent = (event: ClientEvent) => this.onClientEvent?.(observedClient, event, this.context);
|
|
162
|
+
|
|
163
|
+
observedClient.once('close', () => {
|
|
164
|
+
observedClient.off('newpeerconnection', this._onPeerConnconnectionAdded);
|
|
165
|
+
observedClient.off('issue', onClientIssue);
|
|
166
|
+
observedClient.off('metaData', onClientMetadata);
|
|
167
|
+
observedClient.off('joined', onClientJoined);
|
|
168
|
+
observedClient.off('left', onClientLeft);
|
|
169
|
+
observedClient.off('rejoined', onClientJoined);
|
|
170
|
+
observedClient.off('usermediaerror', onUserMediaError);
|
|
171
|
+
observedClient.off('usingturn', onUsingTurn);
|
|
172
|
+
observedClient.off('extensionStats', onClientExtensionStats);
|
|
173
|
+
observedClient.off('update', onClientUpdated);
|
|
174
|
+
observedClient.off('clientEvent', onClientEvent);
|
|
175
|
+
|
|
176
|
+
this.onClientClosed?.(observedClient, this.context);
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
observedClient.on('newpeerconnection', this._onPeerConnconnectionAdded);
|
|
180
|
+
observedClient.on('issue', onClientIssue);
|
|
181
|
+
observedClient.on('metaData', onClientMetadata);
|
|
182
|
+
observedClient.on('joined', onClientJoined);
|
|
183
|
+
observedClient.on('left', onClientLeft);
|
|
184
|
+
observedClient.on('rejoined', onClientRejoined);
|
|
185
|
+
observedClient.on('usermediaerror', onUserMediaError);
|
|
186
|
+
observedClient.on('usingturn', onUsingTurn);
|
|
187
|
+
observedClient.on('extensionStats', onClientExtensionStats);
|
|
188
|
+
observedClient.on('update', onClientUpdated);
|
|
189
|
+
observedClient.on('clientEvent', onClientEvent);
|
|
190
|
+
|
|
191
|
+
this.onClientAdded?.(observedClient, this.context);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
private _onClientRejoined(observedClient: ObservedClient) {
|
|
195
|
+
this.onClientRejoined?.(observedClient, this.context);
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
private _onPeerConnconnectionAdded(peerConnection: ObservedPeerConnection) {
|
|
199
|
+
const onSelectedCandidatePairChanged = () => this.onSelectedCandidatePairChanged?.(peerConnection, this.context);
|
|
200
|
+
const onIceGatheringStateChange = () => this.onIceGatheringStateChange?.(peerConnection, this.context);
|
|
201
|
+
const onIceConnectionStateChange = () => this.onIceConnectionStateChange?.(peerConnection, this.context);
|
|
202
|
+
const onConnectionStateChange = () => this.onConnectionStateChange?.(peerConnection, this.context);
|
|
203
|
+
|
|
204
|
+
peerConnection.once('close', () => {
|
|
205
|
+
peerConnection.off('added-certificate', this._onCertificateAdded);
|
|
206
|
+
peerConnection.off('removed-certificate', this._onCertificateRemoved);
|
|
207
|
+
peerConnection.off('added-inbound-track', this._onInboundTrackAdded);
|
|
208
|
+
peerConnection.off('removed-inbound-track', this._onInboundTrackRemoved);
|
|
209
|
+
peerConnection.off('added-outbound-track', this._onOutboundTrackAdded);
|
|
210
|
+
peerConnection.off('removed-outbound-track', this._onOutboundTrackRemoved);
|
|
211
|
+
peerConnection.off('added-inbound-rtp', this._onInboundRtpAdded);
|
|
212
|
+
peerConnection.off('removed-inbound-rtp', this._onInboundRtpRemoved);
|
|
213
|
+
peerConnection.off('added-outbound-rtp', this._onOutboundRtpAdded);
|
|
214
|
+
peerConnection.off('removed-outbound-rtp', this._onOutboundRtpRemoved);
|
|
215
|
+
peerConnection.off('added-data-channel', this._onDataChannelAdded);
|
|
216
|
+
peerConnection.off('removed-data-channel', this._onDataChannelRemoved);
|
|
217
|
+
peerConnection.off('added-ice-transport', this._onAddedIceTransport);
|
|
218
|
+
peerConnection.off('removed-ice-transport', this._onRemovedIceTransport);
|
|
219
|
+
peerConnection.off('added-ice-candidate', this._onIceCandidateAdded);
|
|
220
|
+
peerConnection.off('removed-ice-candidate', this._onIceCandidateRemoved);
|
|
221
|
+
peerConnection.off('added-ice-candidate-pair', this._onAddedIceCandidatePair);
|
|
222
|
+
peerConnection.off('removed-ice-candidate-pair', this._onRemovedIceCandidatePair);
|
|
223
|
+
peerConnection.off('added-codec', this._onAddedMediaCodec);
|
|
224
|
+
peerConnection.off('removed-codec', this._onRemovedMediaCodec);
|
|
225
|
+
peerConnection.off('added-media-playout', this._onAddedMediaPlayout);
|
|
226
|
+
peerConnection.off('removed-media-playout', this._onRemovedMediaPlayout);
|
|
227
|
+
peerConnection.off('added-media-source', this._onMediaSourceAdded);
|
|
228
|
+
peerConnection.off('removed-media-source', this._onMediaSourceRemoved);
|
|
229
|
+
peerConnection.off('selectedcandidatepair', onSelectedCandidatePairChanged);
|
|
230
|
+
peerConnection.off('icegatheringstatechange', onIceGatheringStateChange);
|
|
231
|
+
peerConnection.off('iceconnectionstatechange', onIceConnectionStateChange);
|
|
232
|
+
peerConnection.off('connectionstatechange', onConnectionStateChange);
|
|
233
|
+
|
|
234
|
+
this.onPeerConnectionRemoved?.(peerConnection, this.context);
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
peerConnection.on('added-certificate', this._onCertificateAdded);
|
|
238
|
+
peerConnection.on('removed-certificate', this._onCertificateRemoved);
|
|
239
|
+
peerConnection.on('added-inbound-track', this._onInboundTrackAdded);
|
|
240
|
+
peerConnection.on('removed-inbound-track', this._onInboundTrackRemoved);
|
|
241
|
+
peerConnection.on('added-outbound-track', this._onOutboundTrackAdded);
|
|
242
|
+
peerConnection.on('removed-outbound-track', this._onOutboundTrackRemoved);
|
|
243
|
+
peerConnection.on('added-inbound-rtp', this._onInboundRtpAdded);
|
|
244
|
+
peerConnection.on('removed-inbound-rtp', this._onInboundRtpRemoved);
|
|
245
|
+
peerConnection.on('added-outbound-rtp', this._onOutboundRtpAdded);
|
|
246
|
+
peerConnection.on('removed-outbound-rtp', this._onOutboundRtpRemoved);
|
|
247
|
+
peerConnection.on('added-data-channel', this._onDataChannelAdded);
|
|
248
|
+
peerConnection.on('removed-data-channel', this._onDataChannelRemoved);
|
|
249
|
+
peerConnection.on('added-ice-transport', this._onAddedIceTransport);
|
|
250
|
+
peerConnection.on('removed-ice-transport', this._onRemovedIceTransport);
|
|
251
|
+
peerConnection.on('added-ice-candidate', this._onIceCandidateAdded);
|
|
252
|
+
peerConnection.on('removed-ice-candidate', this._onIceCandidateRemoved);
|
|
253
|
+
peerConnection.on('added-ice-candidate-pair', this._onAddedIceCandidatePair);
|
|
254
|
+
peerConnection.on('removed-ice-candidate-pair', this._onRemovedIceCandidatePair);
|
|
255
|
+
peerConnection.on('added-codec', this._onAddedMediaCodec);
|
|
256
|
+
peerConnection.on('removed-codec', this._onRemovedMediaCodec);
|
|
257
|
+
peerConnection.on('added-media-playout', this._onAddedMediaPlayout);
|
|
258
|
+
peerConnection.on('removed-media-playout', this._onRemovedMediaPlayout);
|
|
259
|
+
peerConnection.on('added-media-source', this._onMediaSourceAdded);
|
|
260
|
+
peerConnection.on('removed-media-source', this._onMediaSourceRemoved);
|
|
261
|
+
peerConnection.on('selectedcandidatepair', onSelectedCandidatePairChanged);
|
|
262
|
+
peerConnection.on('icegatheringstatechange', onIceGatheringStateChange);
|
|
263
|
+
peerConnection.on('iceconnectionstatechange', onIceConnectionStateChange);
|
|
264
|
+
peerConnection.on('connectionstatechange', onConnectionStateChange);
|
|
265
|
+
|
|
266
|
+
this.onPeerConnectionAdded?.(peerConnection, this.context);
|
|
267
|
+
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
private _onPeerConnectionRemoved(peerConnection: ObservedPeerConnection) {
|
|
271
|
+
this.onPeerConnectionRemoved?.(peerConnection, this.context);
|
|
272
|
+
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
private _onCertificateAdded(certificate: ObservedCertificate) {
|
|
276
|
+
this.onCertificateAdded?.(certificate, this.context);
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
private _onCertificateRemoved(certificate: ObservedCertificate) {
|
|
280
|
+
this.onCertificateRemoved?.(certificate, this.context);
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
private _onInboundTrackAdded(inboundTrack: ObservedInboundTrack) {
|
|
284
|
+
this.onInboundTrackAdded?.(inboundTrack, this.context);
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
private _onInboundTrackRemoved(inboundTrack: ObservedInboundTrack) {
|
|
288
|
+
this.onInboundTrackRemoved?.(inboundTrack, this.context);
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
private _onOutboundTrackAdded(outboundTrack: ObservedOutboundTrack) {
|
|
292
|
+
this.onOutboundTrackAdded?.(outboundTrack, this.context);
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
private _onOutboundTrackRemoved(outboundTrack: ObservedOutboundTrack) {
|
|
296
|
+
this.onOutboundTrackRemoved?.(outboundTrack, this.context);
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
private _onInboundRtpAdded(inboundRtp: ObservedInboundRtp) {
|
|
300
|
+
this.onInboundRtpAdded?.(inboundRtp, this.context);
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
private _onInboundRtpRemoved(inboundRtp: ObservedInboundRtp) {
|
|
304
|
+
this.onInboundRtpRemoved?.(inboundRtp, this.context);
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
private _onOutboundRtpAdded(outboundRtp: ObservedOutboundRtp) {
|
|
308
|
+
this.onOutboundRtpAdded?.(outboundRtp, this.context);
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
private _onOutboundRtpRemoved(outboundRtp: ObservedOutboundRtp) {
|
|
312
|
+
this.onOutboundRtpRemoved?.(outboundRtp, this.context);
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
private _onDataChannelAdded(dataChannel: ObservedDataChannel) {
|
|
316
|
+
this.onDataChannelAdded?.(dataChannel, this.context);
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
private _onDataChannelRemoved(dataChannel: ObservedDataChannel) {
|
|
320
|
+
this.onDataChannelRemoved?.(dataChannel, this.context);
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
private _onAddedIceTransport(iceTransport: ObservedIceTransport) {
|
|
324
|
+
this.onAddedIceTransport?.(iceTransport, this.context);
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
private _onRemovedIceTransport(iceTransport: ObservedIceTransport) {
|
|
328
|
+
this.onRemovedIceTransport?.(iceTransport, this.context);
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
private _onIceCandidateAdded(iceCandidate: ObservedIceCandidate) {
|
|
332
|
+
this.onIceCandidateAdded?.(iceCandidate, this.context);
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
private _onIceCandidateRemoved(iceCandidate: ObservedIceCandidate) {
|
|
336
|
+
this.onIceCandidateRemoved?.(iceCandidate, this.context);
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
private _onAddedIceCandidatePair(candidatePair: ObservedIceCandidatePair) {
|
|
340
|
+
this.onAddedIceCandidatePair?.(candidatePair, this.context);
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
private _onRemovedIceCandidatePair(candidatePair: ObservedIceCandidatePair) {
|
|
344
|
+
this.onRemovedIceCandidatePair?.(candidatePair, this.context);
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
private _onAddedMediaCodec(codec: ObservedCodec) {
|
|
348
|
+
this.onAddedMediaCodec?.(codec, this.context);
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
private _onRemovedMediaCodec(codec: ObservedCodec) {
|
|
352
|
+
this.onRemovedMediaCodec?.(codec, this.context);
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
private _onAddedMediaPlayout(mediaPlayout: ObservedMediaPlayout) {
|
|
356
|
+
this.onAddedMediaPlayout?.(mediaPlayout, this.context);
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
private _onRemovedMediaPlayout(mediaPlayout: ObservedMediaPlayout) {
|
|
360
|
+
this.onRemovedMediaPlayout?.(mediaPlayout, this.context);
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
private _onMediaSourceAdded(mediaSource: ObservedMediaSource) {
|
|
364
|
+
this.onMediaSourceAdded?.(mediaSource, this.context);
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
private _onMediaSourceRemoved(mediaSource: ObservedMediaSource) {
|
|
368
|
+
this.onMediaSourceRemoved?.(mediaSource, this.context);
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
private _onClientIssue(observedClent: ObservedClient, issue: ClientIssue) {
|
|
372
|
+
this.onClientIssue?.(observedClent, issue, this.context);
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
private _onClientMetadata(observedClient: ObservedClient, metadata: ClientMetaData) {
|
|
376
|
+
this.onClientMetadata?.(observedClient, metadata, this.context);
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
private _onClientExtensionStats(observedClient: ObservedClient, extensionStats: ExtensionStat) {
|
|
380
|
+
this.onClientExtensionStats?.(observedClient, extensionStats, this.context);
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
private _onClientJoined(observedClient: ObservedClient) {
|
|
384
|
+
this.onClientJoined?.(observedClient, this.context);
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
private _onClientLeft(observedClient: ObservedClient) {
|
|
388
|
+
this.onClientLeft?.(observedClient, this.context);
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
private _onUserMediaError(observedClient: ObservedClient, error: string) {
|
|
392
|
+
this.onClientUserMediaError?.(observedClient, error, this.context);
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
private _onUsingTurn(observedClient: ObservedClient, usingTurn: boolean) {
|
|
396
|
+
this.onClientUsingTurn?.(observedClient, usingTurn, this.context);
|
|
397
|
+
}
|
|
398
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -24,5 +24,6 @@ export { ClientMetaTypes } from './schema/ClientMetaTypes';
|
|
|
24
24
|
export { ClientSample } from './schema/ClientSample';
|
|
25
25
|
export { ScoreCalculator } from './scores/ScoreCalculator';
|
|
26
26
|
export { ObservedClientEventMonitor } from './ObservedClientEventMonitor';
|
|
27
|
+
export { ObserverEventMonitor } from './ObserverEventMonitor';
|
|
27
28
|
|
|
28
29
|
export { Middleware } from './common/Middleware';
|
|
@@ -46,6 +46,24 @@ interface MediaTrackCapabilities {
|
|
|
46
46
|
width?: ULongRange;
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
+
interface MediaTrackSettings {
|
|
50
|
+
aspectRatio?: number;
|
|
51
|
+
autoGainControl?: boolean;
|
|
52
|
+
backgroundBlur?: boolean;
|
|
53
|
+
channelCount?: number;
|
|
54
|
+
deviceId?: string;
|
|
55
|
+
displaySurface?: string;
|
|
56
|
+
echoCancellation?: boolean;
|
|
57
|
+
facingMode?: string;
|
|
58
|
+
frameRate?: number;
|
|
59
|
+
groupId?: string;
|
|
60
|
+
height?: number;
|
|
61
|
+
noiseSuppression?: boolean;
|
|
62
|
+
sampleRate?: number;
|
|
63
|
+
sampleSize?: number;
|
|
64
|
+
width?: number;
|
|
65
|
+
}
|
|
66
|
+
|
|
49
67
|
export enum ClientEventTypes {
|
|
50
68
|
CLIENT_JOINED = 'CLIENT_JOINED',
|
|
51
69
|
CLIENT_LEFT = 'CLIENT_LEFT',
|
|
@@ -170,7 +170,7 @@ export type IceCandidatePairStats = {
|
|
|
170
170
|
*/
|
|
171
171
|
remoteCandidateId?: string;
|
|
172
172
|
|
|
173
|
-
state?: 'new' | '
|
|
173
|
+
state?: 'new' | 'in-progress' | 'waiting' | 'failed' | 'succeeded' | 'cancelled' | 'inprogress';
|
|
174
174
|
|
|
175
175
|
/**
|
|
176
176
|
* Whether this candidate pair has been nominated.
|
|
@@ -7,6 +7,7 @@ export class OnAllCallObserverUpdater implements Updater {
|
|
|
7
7
|
public readonly description = 'Call Observer\'s update() method when all of the ObservedCalls are updated';
|
|
8
8
|
|
|
9
9
|
private readonly _updatedCalls = new Set<string>();
|
|
10
|
+
public closed = false;
|
|
10
11
|
|
|
11
12
|
public constructor(
|
|
12
13
|
private observer: Observer
|
|
@@ -20,15 +21,22 @@ export class OnAllCallObserverUpdater implements Updater {
|
|
|
20
21
|
}
|
|
21
22
|
|
|
22
23
|
close(): void {
|
|
23
|
-
|
|
24
|
+
if (this.closed) return;
|
|
25
|
+
this.closed = true;
|
|
26
|
+
|
|
27
|
+
this._updatedCalls.clear();
|
|
24
28
|
}
|
|
25
29
|
|
|
26
30
|
private _onNewObservedCall(observedCall: ObservedCall) {
|
|
31
|
+
if (this.closed) return;
|
|
32
|
+
|
|
27
33
|
const onUpdate = () => this._onObservedCallUpdated(observedCall);
|
|
28
34
|
|
|
29
35
|
observedCall.once('close', () => {
|
|
30
36
|
observedCall.off('update', onUpdate);
|
|
31
37
|
this._updatedCalls.delete(observedCall.callId);
|
|
38
|
+
|
|
39
|
+
this._updateIfEveryCallUpdated();
|
|
32
40
|
});
|
|
33
41
|
observedCall.on('update', onUpdate);
|
|
34
42
|
}
|
|
@@ -38,7 +46,12 @@ export class OnAllCallObserverUpdater implements Updater {
|
|
|
38
46
|
|
|
39
47
|
this._updatedCalls.add(observedCall.callId);
|
|
40
48
|
|
|
49
|
+
this._updateIfEveryCallUpdated();
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
private _updateIfEveryCallUpdated() {
|
|
41
53
|
if (this._updatedCalls.size < this.observer.observedCalls.size) return;
|
|
54
|
+
else if (this.closed) return;
|
|
42
55
|
|
|
43
56
|
this._updatedCalls.clear();
|
|
44
57
|
this.observer.update();
|
|
@@ -7,6 +7,7 @@ export class OnAllClientCallUpdater implements Updater {
|
|
|
7
7
|
readonly description = 'Call the update() method of the ObservedCall once all client has been updated';
|
|
8
8
|
|
|
9
9
|
private readonly _updatedClients = new Set<string>();
|
|
10
|
+
public closed = false;
|
|
10
11
|
|
|
11
12
|
public constructor(
|
|
12
13
|
private _observedCall: ObservedCall
|
|
@@ -20,25 +21,39 @@ export class OnAllClientCallUpdater implements Updater {
|
|
|
20
21
|
}
|
|
21
22
|
|
|
22
23
|
public close(): void {
|
|
24
|
+
if (this.closed) return;
|
|
25
|
+
this.closed = true;
|
|
23
26
|
// do nothing, as close once emitted unsubscription happened
|
|
27
|
+
this._updatedClients.clear();
|
|
24
28
|
}
|
|
25
29
|
|
|
26
30
|
private _onNewObservedClient(observedClient: ObservedClient) {
|
|
31
|
+
if (this.closed) return;
|
|
32
|
+
|
|
27
33
|
const onUpdate = () => this._onClientUpdate(observedClient);
|
|
28
34
|
|
|
29
35
|
observedClient.once('close', () => {
|
|
30
36
|
observedClient.off('update', onUpdate);
|
|
31
37
|
this._updatedClients.delete(observedClient.clientId);
|
|
38
|
+
this._updateIfEveryClientUpdated();
|
|
32
39
|
});
|
|
33
40
|
observedClient.on('update', onUpdate);
|
|
34
41
|
}
|
|
35
42
|
|
|
36
43
|
private _onClientUpdate(observedClient: ObservedClient) {
|
|
44
|
+
if (observedClient.closed) return;
|
|
45
|
+
|
|
37
46
|
this._updatedClients.add(observedClient.clientId);
|
|
47
|
+
this._updateIfEveryClientUpdated();
|
|
48
|
+
}
|
|
38
49
|
|
|
50
|
+
private _updateIfEveryClientUpdated() {
|
|
39
51
|
if (this._updatedClients.size < this._observedCall.observedClients.size) {
|
|
40
52
|
return;
|
|
53
|
+
} else if (this.closed) {
|
|
54
|
+
return;
|
|
41
55
|
}
|
|
56
|
+
|
|
42
57
|
this._updatedClients.clear();
|
|
43
58
|
this._observedCall.update();
|
|
44
59
|
}
|
|
@@ -5,7 +5,8 @@ import { Updater } from './Updater';
|
|
|
5
5
|
export class OnAnyCallObserverUpdater implements Updater {
|
|
6
6
|
public readonly name = 'OnAnyCallObserverUpdater';
|
|
7
7
|
public readonly description = 'Call Observer\'s update() method on any of the ObservedCall is updated';
|
|
8
|
-
|
|
8
|
+
public closed = false;
|
|
9
|
+
|
|
9
10
|
public constructor(
|
|
10
11
|
private observver: Observer
|
|
11
12
|
) {
|
|
@@ -18,11 +19,19 @@ export class OnAnyCallObserverUpdater implements Updater {
|
|
|
18
19
|
}
|
|
19
20
|
|
|
20
21
|
close(): void {
|
|
22
|
+
if (this.closed) return;
|
|
23
|
+
this.closed = true;
|
|
21
24
|
// do nothing, because we unsubscribe once close is emitted from observer
|
|
22
25
|
}
|
|
23
26
|
|
|
24
27
|
private _onNewObservedCall(observedCall: ObservedCall) {
|
|
25
|
-
|
|
28
|
+
if (this.closed) return;
|
|
29
|
+
|
|
30
|
+
const onUpdate = () => {
|
|
31
|
+
if (this.closed) return;
|
|
32
|
+
|
|
33
|
+
this.observver.update();
|
|
34
|
+
};
|
|
26
35
|
|
|
27
36
|
observedCall.once('close', () => {
|
|
28
37
|
observedCall.off('update', onUpdate);
|
|
@@ -5,6 +5,7 @@ import { Updater } from './Updater';
|
|
|
5
5
|
export class OnAnyClientCallUpdater implements Updater {
|
|
6
6
|
readonly name = 'OnAnyClientCallUpdater';
|
|
7
7
|
readonly description = 'Call the update() method of the ObservedCall when any of the client has been updated';
|
|
8
|
+
public closed = false;
|
|
8
9
|
|
|
9
10
|
public constructor(
|
|
10
11
|
private _observedCall: ObservedCall
|
|
@@ -18,11 +19,17 @@ export class OnAnyClientCallUpdater implements Updater {
|
|
|
18
19
|
}
|
|
19
20
|
|
|
20
21
|
public close(): void {
|
|
21
|
-
|
|
22
|
+
if (this.closed) return;
|
|
23
|
+
this.closed = true;
|
|
22
24
|
}
|
|
23
25
|
|
|
24
26
|
private _onNewObservedClient(observedClient: ObservedClient) {
|
|
25
|
-
|
|
27
|
+
if (this.closed) return;
|
|
28
|
+
|
|
29
|
+
const onUpdate = () => {
|
|
30
|
+
if (this.closed) return;
|
|
31
|
+
this._observedCall.update();
|
|
32
|
+
};
|
|
26
33
|
|
|
27
34
|
observedClient.once('close', () => {
|
|
28
35
|
observedClient.off('update', onUpdate);
|