@observertc/observer-js 1.0.1-f31d7a4.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2184 -1
- package/dist/index.d.mts +6842 -0
- package/dist/index.d.ts +6842 -0
- package/dist/index.js +7736 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +7608 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +44 -18
- package/.eslintrc.json +0 -143
- package/.prettierignore +0 -5
- package/.prettierrc +0 -7
- package/jest.config.js +0 -9
- package/lib/ObservedCall.d.ts +0 -62
- package/lib/ObservedCall.d.ts.map +0 -1
- package/lib/ObservedCall.js +0 -127
- package/lib/ObservedCertificate.d.ts +0 -19
- package/lib/ObservedCertificate.d.ts.map +0 -1
- package/lib/ObservedCertificate.js +0 -38
- package/lib/ObservedClient.d.ts +0 -104
- package/lib/ObservedClient.d.ts.map +0 -1
- package/lib/ObservedClient.js +0 -250
- package/lib/ObservedCodec.d.ts +0 -22
- package/lib/ObservedCodec.d.ts.map +0 -1
- package/lib/ObservedCodec.js +0 -45
- package/lib/ObservedDataChannel.d.ts +0 -28
- package/lib/ObservedDataChannel.d.ts.map +0 -1
- package/lib/ObservedDataChannel.js +0 -73
- package/lib/ObservedIceCandidate.d.ts +0 -29
- package/lib/ObservedIceCandidate.d.ts.map +0 -1
- package/lib/ObservedIceCandidate.js +0 -59
- package/lib/ObservedIceCandidatePair.d.ts +0 -44
- package/lib/ObservedIceCandidatePair.d.ts.map +0 -1
- package/lib/ObservedIceCandidatePair.js +0 -111
- package/lib/ObservedIceTransport.d.ts +0 -32
- package/lib/ObservedIceTransport.d.ts.map +0 -1
- package/lib/ObservedIceTransport.js +0 -65
- package/lib/ObservedInboundRtp.d.ts +0 -92
- package/lib/ObservedInboundRtp.d.ts.map +0 -1
- package/lib/ObservedInboundRtp.js +0 -193
- package/lib/ObservedInboundTrack.d.ts +0 -29
- package/lib/ObservedInboundTrack.d.ts.map +0 -1
- package/lib/ObservedInboundTrack.js +0 -57
- package/lib/ObservedMediaPlayout.d.ts +0 -22
- package/lib/ObservedMediaPlayout.d.ts.map +0 -1
- package/lib/ObservedMediaPlayout.js +0 -42
- package/lib/ObservedMediaSource.d.ts +0 -28
- package/lib/ObservedMediaSource.d.ts.map +0 -1
- package/lib/ObservedMediaSource.js +0 -55
- package/lib/ObservedOutboundRtp.d.ts +0 -62
- package/lib/ObservedOutboundRtp.d.ts.map +0 -1
- package/lib/ObservedOutboundRtp.js +0 -144
- package/lib/ObservedOutboundTrack.d.ts +0 -29
- package/lib/ObservedOutboundTrack.d.ts.map +0 -1
- package/lib/ObservedOutboundTrack.js +0 -57
- package/lib/ObservedPeerConnection.d.ts +0 -183
- package/lib/ObservedPeerConnection.d.ts.map +0 -1
- package/lib/ObservedPeerConnection.js +0 -688
- package/lib/ObservedPeerConnectionTransport.d.ts +0 -17
- package/lib/ObservedPeerConnectionTransport.d.ts.map +0 -1
- package/lib/ObservedPeerConnectionTransport.js +0 -34
- package/lib/ObservedRemoteInboundRtp.d.ts +0 -30
- package/lib/ObservedRemoteInboundRtp.d.ts.map +0 -1
- package/lib/ObservedRemoteInboundRtp.js +0 -60
- package/lib/ObservedRemoteOutboundRtp.d.ts +0 -30
- package/lib/ObservedRemoteOutboundRtp.d.ts.map +0 -1
- package/lib/ObservedRemoteOutboundRtp.js +0 -60
- package/lib/ObservedTURN.d.ts +0 -30
- package/lib/ObservedTURN.d.ts.map +0 -1
- package/lib/ObservedTURN.js +0 -54
- package/lib/ObservedTurnServer.d.ts +0 -25
- package/lib/ObservedTurnServer.d.ts.map +0 -1
- package/lib/ObservedTurnServer.js +0 -59
- package/lib/Observer.d.ts +0 -50
- package/lib/Observer.d.ts.map +0 -1
- package/lib/Observer.js +0 -101
- package/lib/common/Middleware.d.ts +0 -17
- package/lib/common/Middleware.d.ts.map +0 -1
- package/lib/common/Middleware.js +0 -60
- package/lib/common/SingleExecutor.d.ts +0 -3
- package/lib/common/SingleExecutor.d.ts.map +0 -1
- package/lib/common/SingleExecutor.js +0 -31
- package/lib/common/logger.d.ts +0 -17
- package/lib/common/logger.d.ts.map +0 -1
- package/lib/common/logger.js +0 -50
- package/lib/common/types.d.ts +0 -3
- package/lib/common/types.d.ts.map +0 -1
- package/lib/common/types.js +0 -3
- package/lib/common/utils.d.ts +0 -10
- package/lib/common/utils.d.ts.map +0 -1
- package/lib/common/utils.js +0 -55
- package/lib/detectors/Detector.d.ts +0 -5
- package/lib/detectors/Detector.d.ts.map +0 -1
- package/lib/detectors/Detector.js +0 -3
- package/lib/detectors/Detectors.d.ts +0 -11
- package/lib/detectors/Detectors.d.ts.map +0 -1
- package/lib/detectors/Detectors.js +0 -34
- package/lib/index.d.ts +0 -26
- package/lib/index.d.ts.map +0 -1
- package/lib/index.js +0 -41
- package/lib/monitors/TurnUsageMonitor.d.ts +0 -1
- package/lib/monitors/TurnUsageMonitor.d.ts.map +0 -1
- package/lib/monitors/TurnUsageMonitor.js +0 -146
- package/lib/schema/ClientEventTypes.d.ts +0 -33
- package/lib/schema/ClientEventTypes.d.ts.map +0 -1
- package/lib/schema/ClientEventTypes.js +0 -38
- package/lib/schema/ClientMetaTypes.d.ts +0 -34
- package/lib/schema/ClientMetaTypes.d.ts.map +0 -1
- package/lib/schema/ClientMetaTypes.js +0 -16
- package/lib/schema/ClientSample.d.ts +0 -1333
- package/lib/schema/ClientSample.d.ts.map +0 -1
- package/lib/schema/ClientSample.js +0 -4
- package/lib/scores/CalculatedScore.d.ts +0 -6
- package/lib/scores/CalculatedScore.d.ts.map +0 -1
- package/lib/scores/CalculatedScore.js +0 -2
- package/lib/scores/DefaultCallScoreCalculator.d.ts +0 -7
- package/lib/scores/DefaultCallScoreCalculator.d.ts.map +0 -1
- package/lib/scores/DefaultCallScoreCalculator.js +0 -21
- package/lib/scores/ScoreCalculator.d.ts +0 -4
- package/lib/scores/ScoreCalculator.d.ts.map +0 -1
- package/lib/scores/ScoreCalculator.js +0 -2
- package/lib/utils/CallUpdater.d.ts +0 -5
- package/lib/utils/CallUpdater.d.ts.map +0 -1
- package/lib/utils/CallUpdater.js +0 -2
- package/lib/utils/OnAllClientCallUpdater.d.ts +0 -16
- package/lib/utils/OnAllClientCallUpdater.d.ts.map +0 -1
- package/lib/utils/OnAllClientCallUpdater.js +0 -58
- package/lib/utils/RemoteTrackResolver.d.ts +0 -7
- package/lib/utils/RemoteTrackResolver.d.ts.map +0 -1
- package/lib/utils/RemoteTrackResolver.js +0 -2
- package/lib/utils/onAnyClientCallUpdater.d.ts +0 -14
- package/lib/utils/onAnyClientCallUpdater.d.ts.map +0 -1
- package/lib/utils/onAnyClientCallUpdater.js +0 -51
- package/src/ObservedCall.ts +0 -176
- package/src/ObservedCertificate.ts +0 -43
- package/src/ObservedClient.ts +0 -324
- package/src/ObservedCodec.ts +0 -49
- package/src/ObservedDataChannel.ts +0 -82
- package/src/ObservedIceCandidate.ts +0 -64
- package/src/ObservedIceCandidatePair.ts +0 -118
- package/src/ObservedIceTransport.ts +0 -70
- package/src/ObservedInboundRtp.ts +0 -205
- package/src/ObservedInboundTrack.ts +0 -70
- package/src/ObservedMediaPlayout.ts +0 -49
- package/src/ObservedMediaSource.ts +0 -60
- package/src/ObservedOutboundRtp.ts +0 -156
- package/src/ObservedOutboundTrack.ts +0 -69
- package/src/ObservedPeerConnection.ts +0 -995
- package/src/ObservedPeerConnectionTransport.ts +0 -38
- package/src/ObservedRemoteInboundRtp.ts +0 -64
- package/src/ObservedRemoteOutboundRtp.ts +0 -65
- package/src/ObservedTURN.ts +0 -80
- package/src/ObservedTurnServer.ts +0 -72
- package/src/Observer.ts +0 -152
- package/src/common/Middleware.ts +0 -84
- package/src/common/SingleExecutor.ts +0 -36
- package/src/common/logger.ts +0 -82
- package/src/common/types.ts +0 -4
- package/src/common/utils.ts +0 -59
- package/src/detectors/Detector.ts +0 -6
- package/src/detectors/Detectors.ts +0 -38
- package/src/index.ts +0 -27
- package/src/monitors/TurnUsageMonitor.ts +0 -187
- package/src/schema/ClientEventTypes.ts +0 -36
- package/src/schema/ClientMetaTypes.ts +0 -41
- package/src/schema/ClientSample.ts +0 -1682
- package/src/scores/CalculatedScore.ts +0 -6
- package/src/scores/DefaultCallScoreCalculator.ts +0 -23
- package/src/scores/ScoreCalculator.ts +0 -3
- package/src/utils/CallUpdater.ts +0 -5
- package/src/utils/OnAllClientCallUpdater.ts +0 -68
- package/src/utils/RemoteTrackResolver.ts +0 -12
- package/src/utils/onAnyClientCallUpdater.ts +0 -59
- package/tsconfig.json +0 -19
- package/tslint.json +0 -6
package/src/ObservedClient.ts
DELETED
|
@@ -1,324 +0,0 @@
|
|
|
1
|
-
import { EventEmitter } from 'events';
|
|
2
|
-
import { ObservedPeerConnection } from './ObservedPeerConnection';
|
|
3
|
-
import { createLogger } from './common/logger';
|
|
4
|
-
// eslint-disable-next-line camelcase
|
|
5
|
-
import { ClientEvent, ClientMetaData, ClientSample, PeerConnectionSample, ClientIssue, ExtensionStat } from './schema/ClientSample';
|
|
6
|
-
import * as MetaData from './schema/ClientMetaTypes';
|
|
7
|
-
import { ClientEventTypes } from './schema/ClientEventTypes';
|
|
8
|
-
import { ObservedCall } from './ObservedCall';
|
|
9
|
-
import { ClientMetaTypes } from './schema/ClientMetaTypes';
|
|
10
|
-
import { parseJsonAs } from './common/utils';
|
|
11
|
-
import { CalculatedScore } from './scores/CalculatedScore';
|
|
12
|
-
import { Detectors } from './detectors/Detectors';
|
|
13
|
-
|
|
14
|
-
const logger = createLogger('ObservedClient');
|
|
15
|
-
|
|
16
|
-
export type ObservedClientSettings<AppData extends Record<string, unknown> = Record<string, unknown>> = {
|
|
17
|
-
clientId: string;
|
|
18
|
-
appData?: AppData;
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
export type ObservedClientEvents = {
|
|
22
|
-
update: [
|
|
23
|
-
{
|
|
24
|
-
sample: ClientSample;
|
|
25
|
-
elapsedTimeInMs: number;
|
|
26
|
-
}
|
|
27
|
-
];
|
|
28
|
-
close: [];
|
|
29
|
-
joined: [];
|
|
30
|
-
issue: [ClientIssue];
|
|
31
|
-
metaData: [ClientMetaData];
|
|
32
|
-
rejoined: [timestamp: number];
|
|
33
|
-
left: [];
|
|
34
|
-
usingturn: [boolean];
|
|
35
|
-
usermediaerror: [string];
|
|
36
|
-
|
|
37
|
-
// do we need this?
|
|
38
|
-
newpeerconnection: [ObservedPeerConnection];
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
export declare interface ObservedClient {
|
|
42
|
-
on<U extends keyof ObservedClientEvents>(event: U, listener: (...args: ObservedClientEvents[U]) => void): this;
|
|
43
|
-
off<U extends keyof ObservedClientEvents>(event: U, listener: (...args: ObservedClientEvents[U]) => void): this;
|
|
44
|
-
once<U extends keyof ObservedClientEvents>(event: U, listener: (...args: ObservedClientEvents[U]) => void): this;
|
|
45
|
-
emit<U extends keyof ObservedClientEvents>(event: U, ...args: ObservedClientEvents[U]): boolean;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
export class ObservedClient<AppData extends Record<string, unknown> = Record<string, unknown>> extends EventEmitter {
|
|
49
|
-
public readonly detectors: Detectors;
|
|
50
|
-
|
|
51
|
-
public readonly clientId: string;
|
|
52
|
-
public readonly observedPeerConnections = new Map<string, ObservedPeerConnection>();
|
|
53
|
-
public readonly calculatedScore: CalculatedScore = {
|
|
54
|
-
weight: 1,
|
|
55
|
-
value: undefined,
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
public appData?: AppData;
|
|
59
|
-
public attachments?: Record<string, unknown>;
|
|
60
|
-
|
|
61
|
-
public updated = Date.now();
|
|
62
|
-
public acceptedSamples = 0;
|
|
63
|
-
public closed = false;
|
|
64
|
-
|
|
65
|
-
public joinedAt?: number;
|
|
66
|
-
public leftAt?: number;
|
|
67
|
-
// the timestamp of the CLIENT_JOINED event
|
|
68
|
-
public operationSystem?: MetaData.OperationSystem;
|
|
69
|
-
public engine?: MetaData.Engine;
|
|
70
|
-
public platform?: MetaData.Platform;
|
|
71
|
-
public browser?: MetaData.Browser;
|
|
72
|
-
public mediaConstraints: string[] = [];
|
|
73
|
-
|
|
74
|
-
public usingTURN = false;
|
|
75
|
-
public availableOutgoingBitrate = 0;
|
|
76
|
-
public availableIncomingBitrate = 0;
|
|
77
|
-
public totalInboundPacketsLost = 0;
|
|
78
|
-
public totalInboundPacketsReceived = 0;
|
|
79
|
-
public totalOutboundPacketsSent = 0;
|
|
80
|
-
public totalDataChannelBytesSent = 0;
|
|
81
|
-
public totalDataChannelBytesReceived = 0;
|
|
82
|
-
public totalDataChannelMessagesSent = 0;
|
|
83
|
-
public totalDataChannelMessagesReceived = 0;
|
|
84
|
-
public totalSentBytes = 0;
|
|
85
|
-
public totalReceivedBytes = 0;
|
|
86
|
-
public totalReceivedAudioBytes = 0;
|
|
87
|
-
public totalReceivedVideoBytes = 0;
|
|
88
|
-
public totalSentAudioBytes = 0;
|
|
89
|
-
public totalSentVideoBytes = 0;
|
|
90
|
-
|
|
91
|
-
public deltaReceivedAudioBytes = 0;
|
|
92
|
-
public deltaReceivedVideoBytes = 0;
|
|
93
|
-
public deltaSentAudioBytes = 0;
|
|
94
|
-
public deltaSentVideoBytes = 0;
|
|
95
|
-
public deltaDataChannelBytesSent = 0;
|
|
96
|
-
public deltaDataChannelBytesReceived = 0;
|
|
97
|
-
public deltaDataChannelMessagesSent = 0;
|
|
98
|
-
public deltaDataChannelMessagesReceived = 0;
|
|
99
|
-
public deltaInboundPacketsLost = 0;
|
|
100
|
-
public deltaInboundPacketsReceived = 0;
|
|
101
|
-
public deltaOutboundPacketsSent = 0;
|
|
102
|
-
|
|
103
|
-
public avgRttInMs?: number;
|
|
104
|
-
public sendingAudioBitrate = 0;
|
|
105
|
-
public sendingVideoBitrate = 0;
|
|
106
|
-
public receivingAudioBitrate = 0;
|
|
107
|
-
public receivingVideoBitrate = 0;
|
|
108
|
-
|
|
109
|
-
public numberOfInboundRtpStreams = 0;
|
|
110
|
-
public numberOfInbundTracks = 0;
|
|
111
|
-
public numberOfOutboundRtpStreams = 0;
|
|
112
|
-
public numberOfOutboundTracks = 0;
|
|
113
|
-
public numberOfDataChannels = 0;
|
|
114
|
-
|
|
115
|
-
public readonly mediaDevices: MetaData.MediaDeviceInfo[] = [];
|
|
116
|
-
public issues: ClientIssue[] = [];
|
|
117
|
-
|
|
118
|
-
public constructor(settings: ObservedClientSettings<AppData>, public readonly call: ObservedCall) {
|
|
119
|
-
super();
|
|
120
|
-
this.setMaxListeners(Infinity);
|
|
121
|
-
|
|
122
|
-
this.clientId = settings.clientId;
|
|
123
|
-
this.appData = settings.appData;
|
|
124
|
-
this.detectors = new Detectors();
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
public get numberOfPeerConnections() {
|
|
128
|
-
return this.observedPeerConnections.size;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
public get score() {
|
|
132
|
-
return this.calculatedScore.value;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
public close() {
|
|
136
|
-
if (this.closed) return;
|
|
137
|
-
this.closed = true;
|
|
138
|
-
|
|
139
|
-
Array.from(this.observedPeerConnections.values()).forEach((peerConnection) => peerConnection.close());
|
|
140
|
-
|
|
141
|
-
this.emit('close');
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
public accept(sample: ClientSample): void {
|
|
145
|
-
if (this.closed) throw new Error(`Client ${this.clientId} is closed`);
|
|
146
|
-
|
|
147
|
-
const now = Date.now();
|
|
148
|
-
const elapsedInMs = now - this.updated;
|
|
149
|
-
const elapsedInSeconds = elapsedInMs / 1000;
|
|
150
|
-
|
|
151
|
-
++this.acceptedSamples;
|
|
152
|
-
|
|
153
|
-
this.availableIncomingBitrate = 0;
|
|
154
|
-
this.availableOutgoingBitrate = 0;
|
|
155
|
-
this.deltaDataChannelBytesReceived = 0;
|
|
156
|
-
this.deltaDataChannelBytesSent = 0;
|
|
157
|
-
this.deltaDataChannelMessagesReceived = 0;
|
|
158
|
-
this.deltaDataChannelMessagesSent = 0;
|
|
159
|
-
this.deltaInboundPacketsLost = 0;
|
|
160
|
-
this.deltaInboundPacketsReceived = 0;
|
|
161
|
-
this.deltaOutboundPacketsSent = 0;
|
|
162
|
-
this.deltaReceivedAudioBytes = 0;
|
|
163
|
-
this.deltaReceivedVideoBytes = 0;
|
|
164
|
-
this.deltaSentAudioBytes = 0;
|
|
165
|
-
this.deltaSentVideoBytes = 0;
|
|
166
|
-
|
|
167
|
-
this.numberOfDataChannels = 0;
|
|
168
|
-
this.numberOfInboundRtpStreams = 0;
|
|
169
|
-
this.numberOfInbundTracks = 0;
|
|
170
|
-
this.numberOfOutboundRtpStreams = 0;
|
|
171
|
-
this.numberOfOutboundTracks = 0;
|
|
172
|
-
|
|
173
|
-
sample.clientEvents?.forEach(this._processClientEvent.bind(this));
|
|
174
|
-
sample.clientMetaItems?.forEach(this.processMetadata.bind(this));
|
|
175
|
-
sample.clientIssues?.forEach(this.addIssue.bind(this));
|
|
176
|
-
sample.peerConnections?.forEach(this._updatePeerConnection.bind(this));
|
|
177
|
-
sample.extensionStats?.forEach(this.addExtensionStats.bind(this));
|
|
178
|
-
|
|
179
|
-
// emit new attachments?
|
|
180
|
-
this.attachments = sample.attachments;
|
|
181
|
-
|
|
182
|
-
this.totalDataChannelBytesReceived += this.deltaDataChannelBytesReceived;
|
|
183
|
-
this.totalDataChannelBytesSent += this.deltaDataChannelBytesSent;
|
|
184
|
-
this.totalDataChannelMessagesReceived += this.deltaDataChannelMessagesReceived;
|
|
185
|
-
this.totalDataChannelMessagesSent += this.deltaDataChannelMessagesSent;
|
|
186
|
-
this.totalInboundPacketsLost += this.deltaInboundPacketsLost;
|
|
187
|
-
this.totalInboundPacketsReceived += this.deltaInboundPacketsReceived;
|
|
188
|
-
this.totalOutboundPacketsSent += this.deltaOutboundPacketsSent;
|
|
189
|
-
this.totalReceivedAudioBytes += this.deltaReceivedAudioBytes;
|
|
190
|
-
this.totalReceivedVideoBytes += this.deltaReceivedVideoBytes;
|
|
191
|
-
this.totalSentAudioBytes += this.deltaSentAudioBytes;
|
|
192
|
-
this.totalSentVideoBytes += this.deltaSentVideoBytes;
|
|
193
|
-
|
|
194
|
-
this.receivingAudioBitrate = (this.deltaReceivedAudioBytes * 8) / (elapsedInSeconds);
|
|
195
|
-
this.receivingVideoBitrate = (this.totalReceivedVideoBytes * 8) / (elapsedInSeconds);
|
|
196
|
-
this.sendingAudioBitrate = (this.deltaSentAudioBytes * 8) / (elapsedInSeconds);
|
|
197
|
-
this.sendingVideoBitrate = (this.deltaSentVideoBytes * 8) / (elapsedInSeconds);
|
|
198
|
-
|
|
199
|
-
this.calculatedScore.value = sample.score;
|
|
200
|
-
this.detectors.update();
|
|
201
|
-
|
|
202
|
-
// emit update
|
|
203
|
-
this.emit('update', {
|
|
204
|
-
sample,
|
|
205
|
-
elapsedTimeInMs: now - this.updated,
|
|
206
|
-
});
|
|
207
|
-
this.updated = now;
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
private _processClientEvent(event: ClientEvent) {
|
|
211
|
-
switch (event.type) {
|
|
212
|
-
case ClientEventTypes.CALL_STARTED: {
|
|
213
|
-
// update call timestamp if it's the first time
|
|
214
|
-
break;
|
|
215
|
-
}
|
|
216
|
-
case ClientEventTypes.CALL_ENDED: {
|
|
217
|
-
// update call timestamp if it's the first time
|
|
218
|
-
break;
|
|
219
|
-
}
|
|
220
|
-
case ClientEventTypes.CLIENT_JOINED: {
|
|
221
|
-
if (event.timestamp) {
|
|
222
|
-
if (!this.joinedAt) {
|
|
223
|
-
this.joinedAt = event.timestamp;
|
|
224
|
-
this.emit('joined');
|
|
225
|
-
} else if (this.joinedAt < event.timestamp) {
|
|
226
|
-
this.emit('rejoined', event.timestamp);
|
|
227
|
-
} else {
|
|
228
|
-
this.joinedAt = event.timestamp;
|
|
229
|
-
logger.warn(`Client ${this.clientId} joinedAt timestamp was updated to ${event.timestamp}. the joined event will not be emitted.`);
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
break;
|
|
233
|
-
}
|
|
234
|
-
case ClientEventTypes.CLIENT_LEFT: {
|
|
235
|
-
if (event.timestamp) {
|
|
236
|
-
if (!this.leftAt) {
|
|
237
|
-
this.leftAt = event.timestamp;
|
|
238
|
-
this.emit('left');
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
break;
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
this.call.observer.emit('client-event', this, event);
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
public processMetadata(metadata: ClientMetaData) {
|
|
249
|
-
switch (metadata.type) {
|
|
250
|
-
case ClientMetaTypes.BROWSER: {
|
|
251
|
-
this.browser = parseJsonAs(metadata.payload);
|
|
252
|
-
break;
|
|
253
|
-
}
|
|
254
|
-
case ClientMetaTypes.ENGINE: {
|
|
255
|
-
this.engine = parseJsonAs(metadata.payload);
|
|
256
|
-
break;
|
|
257
|
-
}
|
|
258
|
-
case ClientMetaTypes.PLATFORM: {
|
|
259
|
-
this.platform = parseJsonAs(metadata.payload);
|
|
260
|
-
break;
|
|
261
|
-
}
|
|
262
|
-
case ClientMetaTypes.OPERATION_SYSTEM: {
|
|
263
|
-
this.operationSystem = parseJsonAs(metadata.payload);
|
|
264
|
-
break;
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
this.call.observer.emit('client-metadata', this, metadata);
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
public addIssue(issue: ClientIssue) {
|
|
272
|
-
this.emit('issue', issue);
|
|
273
|
-
this.call.observer.emit('client-issue', this, issue);
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
public addExtensionStats(stats: ExtensionStat) {
|
|
277
|
-
this.call.observer.emit('client-extension-stats', this, stats);
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
private _updatePeerConnection(sample: PeerConnectionSample) {
|
|
281
|
-
let observedPeerConnection = this.observedPeerConnections.get(sample.peerConnectionId);
|
|
282
|
-
|
|
283
|
-
if (!observedPeerConnection) {
|
|
284
|
-
if (!sample.peerConnectionId) {
|
|
285
|
-
return logger.warn(
|
|
286
|
-
`ObservedClient received an invalid PeerConnectionSample (missing peerConnectionId field). ClientId: ${this.clientId}, CallId: ${this.call.callId}`,
|
|
287
|
-
sample
|
|
288
|
-
);
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
observedPeerConnection = new ObservedPeerConnection(sample.peerConnectionId, this);
|
|
292
|
-
|
|
293
|
-
observedPeerConnection.once('close', () => {
|
|
294
|
-
this.observedPeerConnections.delete(sample.peerConnectionId);
|
|
295
|
-
});
|
|
296
|
-
this.observedPeerConnections.set(sample.peerConnectionId, observedPeerConnection);
|
|
297
|
-
|
|
298
|
-
this.emit('newpeerconnection', observedPeerConnection);
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
observedPeerConnection.accept(sample);
|
|
302
|
-
|
|
303
|
-
this.deltaDataChannelBytesReceived += observedPeerConnection.deltaDataChannelBytesReceived;
|
|
304
|
-
this.deltaDataChannelBytesSent += observedPeerConnection.deltaDataChannelBytesSent;
|
|
305
|
-
this.deltaDataChannelMessagesReceived += observedPeerConnection.deltaDataChannelMessagesReceived;
|
|
306
|
-
this.deltaDataChannelMessagesSent += observedPeerConnection.deltaDataChannelMessagesSent;
|
|
307
|
-
this.deltaInboundPacketsLost += observedPeerConnection.deltaInboundPacketsLost;
|
|
308
|
-
this.deltaInboundPacketsReceived += observedPeerConnection.deltaInboundPacketsReceived;
|
|
309
|
-
this.deltaOutboundPacketsSent += observedPeerConnection.deltaOutboundPacketsSent;
|
|
310
|
-
this.deltaReceivedAudioBytes += observedPeerConnection.deltaReceivedAudioBytes;
|
|
311
|
-
this.deltaReceivedVideoBytes += observedPeerConnection.deltaReceivedVideoBytes;
|
|
312
|
-
this.deltaSentAudioBytes += observedPeerConnection.deltaSentAudioBytes;
|
|
313
|
-
this.deltaSentVideoBytes += observedPeerConnection.deltaSentVideoBytes;
|
|
314
|
-
|
|
315
|
-
this.availableIncomingBitrate += observedPeerConnection.availableIncomingBitrate;
|
|
316
|
-
this.availableOutgoingBitrate += observedPeerConnection.availableOutgoingBitrate;
|
|
317
|
-
|
|
318
|
-
this.numberOfDataChannels += observedPeerConnection.observedDataChannels.size;
|
|
319
|
-
this.numberOfInbundTracks += observedPeerConnection.observedInboundTracks.size;
|
|
320
|
-
this.numberOfOutboundRtpStreams += observedPeerConnection.observedOutboundRtps.size;
|
|
321
|
-
this.numberOfOutboundTracks += observedPeerConnection.observedOutboundTracks.size;
|
|
322
|
-
this.numberOfInboundRtpStreams += observedPeerConnection.observedInboundRtps.size;
|
|
323
|
-
}
|
|
324
|
-
}
|
package/src/ObservedCodec.ts
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { ObservedPeerConnection } from './ObservedPeerConnection';
|
|
2
|
-
import { CodecStats } from './schema/ClientSample';
|
|
3
|
-
|
|
4
|
-
export class ObservedCodec implements CodecStats {
|
|
5
|
-
private _visited = false;
|
|
6
|
-
public appData?: Record<string, unknown>;
|
|
7
|
-
|
|
8
|
-
payloadType?: number | undefined;
|
|
9
|
-
transportId?: string | undefined;
|
|
10
|
-
clockRate?: number | undefined;
|
|
11
|
-
channels?: number | undefined;
|
|
12
|
-
sdpFmtpLine?: string | undefined;
|
|
13
|
-
attachments?: Record<string, unknown> | undefined;
|
|
14
|
-
|
|
15
|
-
public constructor(
|
|
16
|
-
public timestamp: number,
|
|
17
|
-
public id: string,
|
|
18
|
-
public mimeType: string,
|
|
19
|
-
private readonly _peerConnection: ObservedPeerConnection
|
|
20
|
-
) {}
|
|
21
|
-
|
|
22
|
-
public get visited() {
|
|
23
|
-
const visited = this._visited;
|
|
24
|
-
|
|
25
|
-
this._visited = false;
|
|
26
|
-
|
|
27
|
-
return visited;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
public getPeerConnection() {
|
|
31
|
-
return this._peerConnection;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
public getIceTransport() {
|
|
35
|
-
return this._peerConnection.observedIceTransports.get(this.transportId ?? '');
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
public update(stats: CodecStats) {
|
|
39
|
-
this._visited = true;
|
|
40
|
-
|
|
41
|
-
this.timestamp = stats.timestamp;
|
|
42
|
-
this.payloadType = stats.payloadType;
|
|
43
|
-
this.transportId = stats.transportId;
|
|
44
|
-
this.clockRate = stats.clockRate;
|
|
45
|
-
this.channels = stats.channels;
|
|
46
|
-
this.sdpFmtpLine = stats.sdpFmtpLine;
|
|
47
|
-
this.attachments = stats.attachments;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import { ObservedPeerConnection } from './ObservedPeerConnection';
|
|
2
|
-
import { DataChannelStats } from './schema/ClientSample';
|
|
3
|
-
|
|
4
|
-
export type ObservedDataChannelState = 'connecting' | 'open' | 'closing' | 'closed';
|
|
5
|
-
|
|
6
|
-
export class ObservedDataChannel implements DataChannelStats {
|
|
7
|
-
private _visited = false;
|
|
8
|
-
|
|
9
|
-
label?: string | undefined;
|
|
10
|
-
protocol?: string | undefined;
|
|
11
|
-
dataChannelIdentifier?: number | undefined;
|
|
12
|
-
state?: string | undefined;
|
|
13
|
-
messagesSent?: number | undefined;
|
|
14
|
-
bytesSent?: number | undefined;
|
|
15
|
-
messagesReceived?: number | undefined;
|
|
16
|
-
bytesReceived?: number | undefined;
|
|
17
|
-
attachments?: Record<string, unknown> | undefined;
|
|
18
|
-
|
|
19
|
-
public deltaBytesSent = 0;
|
|
20
|
-
public deltaBytesReceived = 0;
|
|
21
|
-
public deltaMessagesSent = 0;
|
|
22
|
-
public deltaMessagesReceived = 0;
|
|
23
|
-
|
|
24
|
-
public appData?: Record<string, unknown>;
|
|
25
|
-
|
|
26
|
-
public constructor(
|
|
27
|
-
public timestamp: number,
|
|
28
|
-
public id: string,
|
|
29
|
-
private readonly _peerConnection: ObservedPeerConnection,
|
|
30
|
-
) {
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
public get visited() {
|
|
34
|
-
const visited = this._visited;
|
|
35
|
-
|
|
36
|
-
this._visited = false;
|
|
37
|
-
|
|
38
|
-
return visited;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
public getPeerConnection() {
|
|
42
|
-
return this._peerConnection;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
public update(stats: DataChannelStats) {
|
|
46
|
-
this._visited = true;
|
|
47
|
-
|
|
48
|
-
if (this.messagesSent && stats.messagesSent && stats.messagesSent >= this.messagesSent) {
|
|
49
|
-
this.deltaMessagesSent = stats.messagesSent - this.messagesSent;
|
|
50
|
-
} else {
|
|
51
|
-
this.deltaMessagesSent = 0;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
if (this.messagesReceived && stats.messagesReceived && stats.messagesReceived >= this.messagesReceived) {
|
|
55
|
-
this.deltaMessagesReceived = stats.messagesReceived - this.messagesReceived;
|
|
56
|
-
} else {
|
|
57
|
-
this.deltaMessagesReceived = 0;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
if (this.bytesSent && stats.bytesSent && stats.bytesSent >= this.bytesSent) {
|
|
61
|
-
this.deltaBytesSent = stats.bytesSent - this.bytesSent;
|
|
62
|
-
} else {
|
|
63
|
-
this.deltaBytesSent = 0;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
if (this.bytesReceived && stats.bytesReceived && stats.bytesReceived >= this.bytesReceived) {
|
|
67
|
-
this.deltaBytesReceived = stats.bytesReceived - this.bytesReceived;
|
|
68
|
-
} else {
|
|
69
|
-
this.deltaBytesReceived = 0;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
this.label = stats.label;
|
|
73
|
-
this.protocol = stats.protocol;
|
|
74
|
-
this.dataChannelIdentifier = stats.dataChannelIdentifier;
|
|
75
|
-
this.state = stats.state;
|
|
76
|
-
this.messagesSent = stats.messagesSent;
|
|
77
|
-
this.bytesSent = stats.bytesSent;
|
|
78
|
-
this.messagesReceived = stats.messagesReceived;
|
|
79
|
-
this.bytesReceived = stats.bytesReceived;
|
|
80
|
-
this.attachments = stats.attachments;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import { ObservedPeerConnection } from './ObservedPeerConnection';
|
|
2
|
-
import { IceCandidateStats } from './schema/ClientSample';
|
|
3
|
-
|
|
4
|
-
export class ObservedIceCandidate implements IceCandidateStats {
|
|
5
|
-
private _visited = false;
|
|
6
|
-
public appData?: Record<string, unknown>;
|
|
7
|
-
|
|
8
|
-
transportId?: string | undefined;
|
|
9
|
-
address?: string | undefined;
|
|
10
|
-
port?: number | undefined;
|
|
11
|
-
protocol?: string | undefined;
|
|
12
|
-
candidateType?: string | undefined;
|
|
13
|
-
priority?: number | undefined;
|
|
14
|
-
url?: string | undefined;
|
|
15
|
-
relayProtocol?: string | undefined;
|
|
16
|
-
foundation?: string | undefined;
|
|
17
|
-
relatedAddress?: string | undefined;
|
|
18
|
-
relatedPort?: number | undefined;
|
|
19
|
-
usernameFragment?: string | undefined;
|
|
20
|
-
tcpType?: string | undefined;
|
|
21
|
-
attachments?: Record<string, unknown> | undefined;
|
|
22
|
-
|
|
23
|
-
public constructor(
|
|
24
|
-
public timestamp: number,
|
|
25
|
-
public id: string,
|
|
26
|
-
private readonly _peerConnection: ObservedPeerConnection
|
|
27
|
-
) {}
|
|
28
|
-
|
|
29
|
-
public get visited() {
|
|
30
|
-
const visited = this._visited;
|
|
31
|
-
|
|
32
|
-
this._visited = false;
|
|
33
|
-
|
|
34
|
-
return visited;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
public getPeerConnection() {
|
|
38
|
-
return this._peerConnection;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
public getIceTransport() {
|
|
42
|
-
return this._peerConnection.observedIceTransports.get(this.transportId ?? '');
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
public update(stats: IceCandidateStats) {
|
|
46
|
-
this._visited = true;
|
|
47
|
-
|
|
48
|
-
this.timestamp = stats.timestamp;
|
|
49
|
-
this.transportId = stats.transportId;
|
|
50
|
-
this.address = stats.address;
|
|
51
|
-
this.port = stats.port;
|
|
52
|
-
this.protocol = stats.protocol;
|
|
53
|
-
this.candidateType = stats.candidateType;
|
|
54
|
-
this.priority = stats.priority;
|
|
55
|
-
this.url = stats.url;
|
|
56
|
-
this.relayProtocol = stats.relayProtocol;
|
|
57
|
-
this.foundation = stats.foundation;
|
|
58
|
-
this.relatedAddress = stats.relatedAddress;
|
|
59
|
-
this.relatedPort = stats.relatedPort;
|
|
60
|
-
this.usernameFragment = stats.usernameFragment;
|
|
61
|
-
this.tcpType = stats.tcpType;
|
|
62
|
-
this.attachments = stats.attachments;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
import { ObservedPeerConnection } from './ObservedPeerConnection';
|
|
2
|
-
import { IceCandidatePairStats } from './schema/ClientSample';
|
|
3
|
-
|
|
4
|
-
export class ObservedIceCandidatePair implements IceCandidatePairStats {
|
|
5
|
-
private _visited = false;
|
|
6
|
-
public appData?: Record<string, unknown>;
|
|
7
|
-
|
|
8
|
-
transportId?: string | undefined;
|
|
9
|
-
localCandidateId?: string | undefined;
|
|
10
|
-
remoteCandidateId?: string | undefined;
|
|
11
|
-
state?: 'new' | 'inProgress' | 'failed' | 'succeeded' | undefined;
|
|
12
|
-
nominated?: boolean | undefined;
|
|
13
|
-
packetsSent?: number | undefined;
|
|
14
|
-
packetsReceived?: number | undefined;
|
|
15
|
-
bytesSent?: number | undefined;
|
|
16
|
-
bytesReceived?: number | undefined;
|
|
17
|
-
lastPacketSentTimestamp?: number | undefined;
|
|
18
|
-
lastPacketReceivedTimestamp?: number | undefined;
|
|
19
|
-
totalRoundTripTime?: number | undefined;
|
|
20
|
-
currentRoundTripTime?: number | undefined;
|
|
21
|
-
availableOutgoingBitrate?: number | undefined;
|
|
22
|
-
availableIncomingBitrate?: number | undefined;
|
|
23
|
-
requestsReceived?: number | undefined;
|
|
24
|
-
requestsSent?: number | undefined;
|
|
25
|
-
responsesReceived?: number | undefined;
|
|
26
|
-
responsesSent?: number | undefined;
|
|
27
|
-
consentRequestsSent?: number | undefined;
|
|
28
|
-
packetsDiscardedOnSend?: number | undefined;
|
|
29
|
-
bytesDiscardedOnSend?: number | undefined;
|
|
30
|
-
attachments?: Record<string, unknown> | undefined;
|
|
31
|
-
|
|
32
|
-
public deltaBytesSent = 0;
|
|
33
|
-
public deltaBytesReceived = 0;
|
|
34
|
-
public deltaPacketsSent = 0;
|
|
35
|
-
public deltaPacketsReceived = 0;
|
|
36
|
-
|
|
37
|
-
public constructor(
|
|
38
|
-
public timestamp: number,
|
|
39
|
-
public id: string,
|
|
40
|
-
private readonly _peerConnection: ObservedPeerConnection,
|
|
41
|
-
) {
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
public get visited() {
|
|
45
|
-
const visited = this._visited;
|
|
46
|
-
|
|
47
|
-
this._visited = false;
|
|
48
|
-
|
|
49
|
-
return visited;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
public getPeerConnection() {
|
|
53
|
-
return this._peerConnection;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
public getIceTransport() {
|
|
57
|
-
return this._peerConnection.observedIceTransports.get(this.transportId ?? '');
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
public getLocalCandidate() {
|
|
61
|
-
return this._peerConnection.observedIceCandidates.get(this.localCandidateId ?? '');
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
public getRemoteCandidate() {
|
|
65
|
-
return this._peerConnection.observedIceCandidates.get(this.remoteCandidateId ?? '');
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
public update(stats: IceCandidatePairStats) {
|
|
69
|
-
this._visited = true;
|
|
70
|
-
|
|
71
|
-
if (this.packetsSent && stats.packetsSent && stats.packetsSent >= this.packetsSent) {
|
|
72
|
-
this.deltaPacketsSent = stats.packetsSent - this.packetsSent;
|
|
73
|
-
} else {
|
|
74
|
-
this.deltaPacketsSent = 0;
|
|
75
|
-
}
|
|
76
|
-
if (this.packetsReceived && stats.packetsReceived && stats.packetsReceived >= this.packetsReceived) {
|
|
77
|
-
this.deltaPacketsReceived = stats.packetsReceived - this.packetsReceived;
|
|
78
|
-
} else {
|
|
79
|
-
this.deltaPacketsReceived = 0;
|
|
80
|
-
}
|
|
81
|
-
if (this.bytesSent && stats.bytesSent && stats.bytesSent >= this.bytesSent) {
|
|
82
|
-
this.deltaBytesSent = stats.bytesSent - this.bytesSent;
|
|
83
|
-
} else {
|
|
84
|
-
this.deltaBytesSent = 0;
|
|
85
|
-
}
|
|
86
|
-
if (this.bytesReceived && stats.bytesReceived && stats.bytesReceived >= this.bytesReceived) {
|
|
87
|
-
this.deltaBytesReceived = stats.bytesReceived - this.bytesReceived;
|
|
88
|
-
} else {
|
|
89
|
-
this.deltaBytesReceived = 0;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
this.timestamp = stats.timestamp;
|
|
93
|
-
this.transportId = stats.transportId;
|
|
94
|
-
this.localCandidateId = stats.localCandidateId;
|
|
95
|
-
this.remoteCandidateId = stats.remoteCandidateId;
|
|
96
|
-
this.state = stats.state;
|
|
97
|
-
this.nominated = stats.nominated;
|
|
98
|
-
this.packetsSent = stats.packetsSent;
|
|
99
|
-
this.packetsReceived = stats.packetsReceived;
|
|
100
|
-
this.bytesSent = stats.bytesSent;
|
|
101
|
-
this.bytesReceived = stats.bytesReceived;
|
|
102
|
-
this.lastPacketSentTimestamp = stats.lastPacketSentTimestamp;
|
|
103
|
-
this.lastPacketReceivedTimestamp = stats.lastPacketReceivedTimestamp;
|
|
104
|
-
this.totalRoundTripTime = stats.totalRoundTripTime;
|
|
105
|
-
this.currentRoundTripTime = stats.currentRoundTripTime;
|
|
106
|
-
this.availableOutgoingBitrate = stats.availableOutgoingBitrate;
|
|
107
|
-
this.availableIncomingBitrate = stats.availableIncomingBitrate;
|
|
108
|
-
this.requestsReceived = stats.requestsReceived;
|
|
109
|
-
this.requestsSent = stats.requestsSent;
|
|
110
|
-
this.responsesReceived = stats.responsesReceived;
|
|
111
|
-
this.responsesSent = stats.responsesSent;
|
|
112
|
-
this.consentRequestsSent = stats.consentRequestsSent;
|
|
113
|
-
this.packetsDiscardedOnSend = stats.packetsDiscardedOnSend;
|
|
114
|
-
this.bytesDiscardedOnSend = stats.bytesDiscardedOnSend;
|
|
115
|
-
this.attachments = stats.attachments;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
}
|