@observertc/observer-js 1.0.0-beta.3 → 1.0.0-beta.5
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 +790 -386
- package/dist/index.d.mts +2795 -0
- package/dist/index.d.ts +2795 -0
- package/dist/index.js +3765 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +3699 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +28 -15
- 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 -70
- package/lib/ObservedCall.d.ts.map +0 -1
- package/lib/ObservedCall.js +0 -196
- package/lib/ObservedCallEventMonitor.d.ts +0 -107
- package/lib/ObservedCallEventMonitor.d.ts.map +0 -1
- package/lib/ObservedCallEventMonitor.js +0 -321
- package/lib/ObservedCallSummary.d.ts +0 -18
- package/lib/ObservedCallSummary.d.ts.map +0 -1
- package/lib/ObservedCallSummary.js +0 -2
- 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 -115
- package/lib/ObservedClient.d.ts.map +0 -1
- package/lib/ObservedClient.js +0 -714
- package/lib/ObservedClientEventMonitor.d.ts +0 -91
- package/lib/ObservedClientEventMonitor.d.ts.map +0 -1
- package/lib/ObservedClientEventMonitor.js +0 -254
- package/lib/ObservedClientSummary.d.ts +0 -23
- package/lib/ObservedClientSummary.d.ts.map +0 -1
- package/lib/ObservedClientSummary.js +0 -2
- 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 -30
- package/lib/ObservedDataChannel.d.ts.map +0 -1
- package/lib/ObservedDataChannel.js +0 -75
- 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 -45
- package/lib/ObservedIceCandidatePair.d.ts.map +0 -1
- package/lib/ObservedIceCandidatePair.js +0 -127
- package/lib/ObservedIceTransport.d.ts +0 -36
- package/lib/ObservedIceTransport.d.ts.map +0 -1
- package/lib/ObservedIceTransport.js +0 -93
- 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 -34
- package/lib/ObservedInboundTrack.d.ts.map +0 -1
- package/lib/ObservedInboundTrack.js +0 -92
- 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 -34
- package/lib/ObservedOutboundTrack.d.ts.map +0 -1
- package/lib/ObservedOutboundTrack.js +0 -65
- package/lib/ObservedPeerConnection.d.ts +0 -207
- package/lib/ObservedPeerConnection.d.ts.map +0 -1
- package/lib/ObservedPeerConnection.js +0 -788
- 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 -31
- package/lib/ObservedTURN.d.ts.map +0 -1
- package/lib/ObservedTURN.js +0 -58
- 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 -62
- package/lib/Observer.d.ts.map +0 -1
- package/lib/Observer.js +0 -160
- package/lib/ObserverEventMonitor.d.ts +0 -141
- package/lib/ObserverEventMonitor.d.ts.map +0 -1
- package/lib/ObserverEventMonitor.js +0 -440
- package/lib/ObserverSummary.d.ts +0 -13
- package/lib/ObserverSummary.d.ts.map +0 -1
- package/lib/ObserverSummary.js +0 -2
- package/lib/Reports.d.ts +0 -85
- package/lib/Reports.d.ts.map +0 -1
- package/lib/Reports.js +0 -2
- 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 -11
- package/lib/common/utils.d.ts.map +0 -1
- package/lib/common/utils.js +0 -63
- 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 -29
- package/lib/index.d.ts.map +0 -1
- package/lib/index.js +0 -49
- package/lib/mediasoup/ObservedMediaRouter.d.ts +0 -10
- package/lib/mediasoup/ObservedMediaRouter.d.ts.map +0 -1
- package/lib/mediasoup/ObservedMediaRouter.js +0 -6
- 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 -228
- package/lib/schema/ClientEventTypes.d.ts.map +0 -1
- package/lib/schema/ClientEventTypes.js +0 -41
- 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/updaters/CallUpdater.d.ts +0 -5
- package/lib/updaters/CallUpdater.d.ts.map +0 -1
- package/lib/updaters/CallUpdater.js +0 -2
- package/lib/updaters/ObserverUpdater.d.ts +0 -5
- package/lib/updaters/ObserverUpdater.d.ts.map +0 -1
- package/lib/updaters/ObserverUpdater.js +0 -2
- package/lib/updaters/OnAllCallObserverUpdater.d.ts +0 -15
- package/lib/updaters/OnAllCallObserverUpdater.d.ts.map +0 -1
- package/lib/updaters/OnAllCallObserverUpdater.js +0 -50
- package/lib/updaters/OnAllClientCallUpdater.d.ts +0 -15
- package/lib/updaters/OnAllClientCallUpdater.d.ts.map +0 -1
- package/lib/updaters/OnAllClientCallUpdater.js +0 -53
- package/lib/updaters/OnAnyCallObserverUpdater.d.ts +0 -12
- package/lib/updaters/OnAnyCallObserverUpdater.d.ts.map +0 -1
- package/lib/updaters/OnAnyCallObserverUpdater.js +0 -37
- package/lib/updaters/OnAnyClientCallUpdater.d.ts +0 -12
- package/lib/updaters/OnAnyClientCallUpdater.d.ts.map +0 -1
- package/lib/updaters/OnAnyClientCallUpdater.js +0 -36
- package/lib/updaters/OnIntervalUpdater.d.ts +0 -10
- package/lib/updaters/OnIntervalUpdater.d.ts.map +0 -1
- package/lib/updaters/OnIntervalUpdater.js +0 -17
- package/lib/updaters/Updater.d.ts +0 -6
- package/lib/updaters/Updater.d.ts.map +0 -1
- package/lib/updaters/Updater.js +0 -2
- package/lib/utils/MediasoupRemoteTrackResolver.d.ts +0 -25
- package/lib/utils/MediasoupRemoteTrackResolver.d.ts.map +0 -1
- package/lib/utils/MediasoupRemoteTrackResolver.js +0 -110
- 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/src/ObservedCall.ts +0 -308
- package/src/ObservedCallEventMonitor.ts +0 -402
- package/src/ObservedCallSummary.ts +0 -22
- package/src/ObservedCertificate.ts +0 -43
- package/src/ObservedClient.ts +0 -883
- package/src/ObservedClientEventMonitor.ts +0 -309
- package/src/ObservedClientSummary.ts +0 -24
- package/src/ObservedCodec.ts +0 -49
- package/src/ObservedDataChannel.ts +0 -85
- package/src/ObservedIceCandidate.ts +0 -64
- package/src/ObservedIceCandidatePair.ts +0 -134
- package/src/ObservedIceTransport.ts +0 -99
- package/src/ObservedInboundRtp.ts +0 -205
- package/src/ObservedInboundTrack.ts +0 -105
- package/src/ObservedMediaPlayout.ts +0 -49
- package/src/ObservedMediaSource.ts +0 -60
- package/src/ObservedOutboundRtp.ts +0 -156
- package/src/ObservedOutboundTrack.ts +0 -82
- package/src/ObservedPeerConnection.ts +0 -1104
- package/src/ObservedPeerConnectionTransport.ts +0 -38
- package/src/ObservedRemoteInboundRtp.ts +0 -64
- package/src/ObservedRemoteOutboundRtp.ts +0 -65
- package/src/ObservedTURN.ts +0 -86
- package/src/ObservedTurnServer.ts +0 -72
- package/src/Observer.ts +0 -248
- package/src/ObserverEventMonitor.ts +0 -561
- package/src/ObserverSummary.ts +0 -15
- package/src/Reports.ts +0 -87
- 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 -69
- package/src/detectors/Detector.ts +0 -6
- package/src/detectors/Detectors.ts +0 -38
- package/src/index.ts +0 -32
- package/src/mediasoup/ObservedMediaRouter.ts +0 -10
- package/src/monitors/TurnUsageMonitor.ts +0 -187
- package/src/schema/ClientEventTypes.ts +0 -280
- 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/updaters/CallUpdater.ts +0 -5
- package/src/updaters/ObserverUpdater.ts +0 -5
- package/src/updaters/OnAllCallObserverUpdater.ts +0 -59
- package/src/updaters/OnAllClientCallUpdater.ts +0 -61
- package/src/updaters/OnAnyCallObserverUpdater.ts +0 -41
- package/src/updaters/OnAnyClientCallUpdater.ts +0 -39
- package/src/updaters/OnIntervalUpdater.ts +0 -19
- package/src/updaters/Updater.ts +0 -5
- package/src/utils/MediasoupRemoteTrackResolver.ts +0 -155
- package/src/utils/RemoteTrackResolver.ts +0 -12
- package/tsconfig.json +0 -19
- package/tslint.json +0 -6
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { ObservedPeerConnection } from './ObservedPeerConnection';
|
|
2
|
-
import { PeerConnectionTransportStats } from './schema/ClientSample';
|
|
3
|
-
|
|
4
|
-
export class ObservedPeerConnectionTransport implements PeerConnectionTransportStats {
|
|
5
|
-
private _visited = false;
|
|
6
|
-
public appData?: Record<string, unknown>;
|
|
7
|
-
|
|
8
|
-
dataChannelsOpened?: number | undefined;
|
|
9
|
-
dataChannelsClosed?: number | undefined;
|
|
10
|
-
attachments?: Record<string, unknown> | undefined;
|
|
11
|
-
|
|
12
|
-
public constructor(
|
|
13
|
-
public timestamp: number,
|
|
14
|
-
public id: string,
|
|
15
|
-
private readonly _peerConnection: ObservedPeerConnection
|
|
16
|
-
) {}
|
|
17
|
-
|
|
18
|
-
public get visited() {
|
|
19
|
-
const visited = this._visited;
|
|
20
|
-
|
|
21
|
-
this._visited = false;
|
|
22
|
-
|
|
23
|
-
return visited;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
public getPeerConnection() {
|
|
27
|
-
return this._peerConnection;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
public update(stats: PeerConnectionTransportStats) {
|
|
31
|
-
this._visited = true;
|
|
32
|
-
|
|
33
|
-
this.timestamp = stats.timestamp;
|
|
34
|
-
this.dataChannelsOpened = stats.dataChannelsOpened;
|
|
35
|
-
this.dataChannelsClosed = stats.dataChannelsClosed;
|
|
36
|
-
this.attachments = stats.attachments;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import { MediaKind } from './common/types';
|
|
2
|
-
import { ObservedPeerConnection } from './ObservedPeerConnection';
|
|
3
|
-
import { RemoteInboundRtpStats } from './schema/ClientSample';
|
|
4
|
-
|
|
5
|
-
export class ObservedRemoteInboundRtp implements RemoteInboundRtpStats {
|
|
6
|
-
private _visited = false;
|
|
7
|
-
public appData?: Record<string, unknown>;
|
|
8
|
-
transportId?: string | undefined;
|
|
9
|
-
codecId?: string | undefined;
|
|
10
|
-
packetsReceived?: number | undefined;
|
|
11
|
-
packetsLost?: number | undefined;
|
|
12
|
-
jitter?: number | undefined;
|
|
13
|
-
localId?: string | undefined;
|
|
14
|
-
roundTripTime?: number | undefined;
|
|
15
|
-
totalRoundTripTime?: number | undefined;
|
|
16
|
-
fractionLost?: number | undefined;
|
|
17
|
-
roundTripTimeMeasurements?: number | undefined;
|
|
18
|
-
attachments?: Record<string, unknown> | undefined;
|
|
19
|
-
|
|
20
|
-
public constructor(
|
|
21
|
-
public timestamp: number,
|
|
22
|
-
public id: string,
|
|
23
|
-
public ssrc: number,
|
|
24
|
-
public kind: MediaKind,
|
|
25
|
-
private readonly _peerConnection: ObservedPeerConnection
|
|
26
|
-
) {}
|
|
27
|
-
|
|
28
|
-
public get visited() {
|
|
29
|
-
const visited = this._visited;
|
|
30
|
-
|
|
31
|
-
this._visited = false;
|
|
32
|
-
|
|
33
|
-
return visited;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
public getPeerConnection() {
|
|
37
|
-
return this._peerConnection;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
public getOutboundRtp() {
|
|
41
|
-
return this._peerConnection.observedOutboundRtps.get(this.ssrc);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
public getCodec() {
|
|
45
|
-
return this._peerConnection.observedCodecs.get(this.codecId ?? '');
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
public update(stats: RemoteInboundRtpStats) {
|
|
49
|
-
this._visited = true;
|
|
50
|
-
|
|
51
|
-
this.timestamp = stats.timestamp;
|
|
52
|
-
this.transportId = stats.transportId;
|
|
53
|
-
this.codecId = stats.codecId;
|
|
54
|
-
this.packetsReceived = stats.packetsReceived;
|
|
55
|
-
this.packetsLost = stats.packetsLost;
|
|
56
|
-
this.jitter = stats.jitter;
|
|
57
|
-
this.localId = stats.localId;
|
|
58
|
-
this.roundTripTime = stats.roundTripTime;
|
|
59
|
-
this.totalRoundTripTime = stats.totalRoundTripTime;
|
|
60
|
-
this.fractionLost = stats.fractionLost;
|
|
61
|
-
this.roundTripTimeMeasurements = stats.roundTripTimeMeasurements;
|
|
62
|
-
this.attachments = stats.attachments;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { MediaKind } from './common/types';
|
|
2
|
-
import { ObservedPeerConnection } from './ObservedPeerConnection';
|
|
3
|
-
import { RemoteOutboundRtpStats } from './schema/ClientSample';
|
|
4
|
-
|
|
5
|
-
export class ObservedRemoteOutboundRtp implements RemoteOutboundRtpStats {
|
|
6
|
-
private _visited = false;
|
|
7
|
-
public appData?: Record<string, unknown>;
|
|
8
|
-
|
|
9
|
-
transportId?: string | undefined;
|
|
10
|
-
codecId?: string | undefined;
|
|
11
|
-
packetsSent?: number | undefined;
|
|
12
|
-
bytesSent?: number | undefined;
|
|
13
|
-
localId?: string | undefined;
|
|
14
|
-
remoteTimestamp?: number | undefined;
|
|
15
|
-
reportsSent?: number | undefined;
|
|
16
|
-
roundTripTime?: number | undefined;
|
|
17
|
-
totalRoundTripTime?: number | undefined;
|
|
18
|
-
roundTripTimeMeasurements?: number | undefined;
|
|
19
|
-
attachments?: Record<string, unknown> | undefined;
|
|
20
|
-
|
|
21
|
-
public constructor(
|
|
22
|
-
public timestamp: number,
|
|
23
|
-
public id: string,
|
|
24
|
-
public ssrc: number,
|
|
25
|
-
public kind: MediaKind,
|
|
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 getInboundRtp() {
|
|
42
|
-
return this._peerConnection.observedInboundRtps.get(this.ssrc);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
public getCodec() {
|
|
46
|
-
return this._peerConnection.observedCodecs.get(this.codecId ?? '');
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
public update(stats: RemoteOutboundRtpStats) {
|
|
50
|
-
this._visited = true;
|
|
51
|
-
|
|
52
|
-
this.timestamp = stats.timestamp;
|
|
53
|
-
this.transportId = stats.transportId;
|
|
54
|
-
this.codecId = stats.codecId;
|
|
55
|
-
this.packetsSent = stats.packetsSent;
|
|
56
|
-
this.bytesSent = stats.bytesSent;
|
|
57
|
-
this.localId = stats.localId;
|
|
58
|
-
this.remoteTimestamp = stats.remoteTimestamp;
|
|
59
|
-
this.reportsSent = stats.reportsSent;
|
|
60
|
-
this.roundTripTime = stats.roundTripTime;
|
|
61
|
-
this.totalRoundTripTime = stats.totalRoundTripTime;
|
|
62
|
-
this.roundTripTimeMeasurements = stats.roundTripTimeMeasurements;
|
|
63
|
-
this.attachments = stats.attachments;
|
|
64
|
-
}
|
|
65
|
-
}
|
package/src/ObservedTURN.ts
DELETED
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import { EventEmitter } from 'stream';
|
|
2
|
-
import { ObservedPeerConnection } from './ObservedPeerConnection';
|
|
3
|
-
import { ObservedTurnServer } from './ObservedTurnServer';
|
|
4
|
-
import { createLogger } from './common/logger';
|
|
5
|
-
|
|
6
|
-
const logger = createLogger('ObservedTURN');
|
|
7
|
-
|
|
8
|
-
export type ObservedTURNEventMap = {
|
|
9
|
-
'update': [ObservedTURN];
|
|
10
|
-
'close': [];
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export declare interface ObservedTURN {
|
|
14
|
-
on<U extends keyof ObservedTURNEventMap>(event: U, listener: (...args: ObservedTURNEventMap[U]) => void): this;
|
|
15
|
-
off<U extends keyof ObservedTURNEventMap>(event: U, listener: (...args: ObservedTURNEventMap[U]) => void): this;
|
|
16
|
-
once<U extends keyof ObservedTURNEventMap>(event: U, listener: (...args: ObservedTURNEventMap[U]) => void): this;
|
|
17
|
-
emit<U extends keyof ObservedTURNEventMap>(event: U, ...args: ObservedTURNEventMap[U]): boolean;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export class ObservedTURN extends EventEmitter {
|
|
21
|
-
public totalBytesSent = 0;
|
|
22
|
-
public totalBytesReceived = 0;
|
|
23
|
-
public totalPacketsSent = 0;
|
|
24
|
-
public totalPacketsReceived = 0;
|
|
25
|
-
|
|
26
|
-
public packetsSentPerSecond = 0;
|
|
27
|
-
public packetsReceivedPerSecond = 0;
|
|
28
|
-
public outboundBitrate = 0;
|
|
29
|
-
public inboundBitrate = 0;
|
|
30
|
-
public numberOfClients = 0;
|
|
31
|
-
|
|
32
|
-
public readonly servers = new Map<string, ObservedTurnServer>();
|
|
33
|
-
|
|
34
|
-
public constructor(
|
|
35
|
-
) {
|
|
36
|
-
super();
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
public update() {
|
|
40
|
-
const clientIds = new Set<string>();
|
|
41
|
-
|
|
42
|
-
this.packetsReceivedPerSecond = 0;
|
|
43
|
-
this.packetsSentPerSecond = 0;
|
|
44
|
-
this.outboundBitrate = 0;
|
|
45
|
-
this.inboundBitrate = 0;
|
|
46
|
-
|
|
47
|
-
for (const server of this.servers.values()) {
|
|
48
|
-
server.update();
|
|
49
|
-
server.observedPeerConnections.forEach((pc) => clientIds.add(pc.client.clientId));
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
this.numberOfClients = clientIds.size;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
public addPeerConnection(peerConnection: ObservedPeerConnection) {
|
|
56
|
-
const turnPairs = peerConnection.selectedIceCandidatePairs.filter((pair) => pair.getLocalCandidate()?.candidateType === 'relay' && pair.getRemoteCandidate()?.url?.startsWith('turn:'));
|
|
57
|
-
|
|
58
|
-
if (turnPairs.length !== 1) {
|
|
59
|
-
return (logger.warn(`Expected exactly one TURN pair, but found for peerconnection ${peerConnection.peerConnectionId}`, turnPairs.length), undefined);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
const candidatePair = turnPairs[0];
|
|
63
|
-
const rawUrl = candidatePair.getRemoteCandidate()?.url;
|
|
64
|
-
|
|
65
|
-
if (!rawUrl) {
|
|
66
|
-
return (logger.warn(`No remote candidate URL found for peerconnection ${peerConnection.peerConnectionId}`), undefined);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
const turnUrl = new URL(rawUrl);
|
|
70
|
-
const turnServerUrl = `${turnUrl.protocol}//${turnUrl.hostname}:${turnUrl.port}`;
|
|
71
|
-
let turnServer = this.servers.get(turnServerUrl);
|
|
72
|
-
|
|
73
|
-
if (!turnServer) {
|
|
74
|
-
turnServer = new ObservedTurnServer(turnServerUrl, this);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
return turnServer;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
public removePeerConnection(peerConnection: ObservedPeerConnection) {
|
|
81
|
-
for (const turnServer of this.servers.values()) {
|
|
82
|
-
turnServer.observedPeerConnections.delete(peerConnection.peerConnectionId);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
}
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import { ObservedIceCandidatePair } from './ObservedIceCandidatePair';
|
|
2
|
-
import { ObservedPeerConnection } from './ObservedPeerConnection';
|
|
3
|
-
import { ObservedTURN } from './ObservedTURN';
|
|
4
|
-
|
|
5
|
-
export class ObservedTurnServer {
|
|
6
|
-
public totalBytesSent = 0;
|
|
7
|
-
public totalBytesReceived = 0;
|
|
8
|
-
public totalPacketsSent = 0;
|
|
9
|
-
public totalPacketsReceived = 0;
|
|
10
|
-
|
|
11
|
-
public packetsSentPerSecond = 0;
|
|
12
|
-
public packetsReceivedPerSecond = 0;
|
|
13
|
-
public outboundBitrate = 0;
|
|
14
|
-
public inboundBitrate = 0;
|
|
15
|
-
|
|
16
|
-
public deltaBytesSent = 0;
|
|
17
|
-
public deltaBytesReceived = 0;
|
|
18
|
-
public deltaPacketsSent = 0;
|
|
19
|
-
public deltaPacketsReceived = 0;
|
|
20
|
-
|
|
21
|
-
public readonly observedPeerConnections = new Map<string, ObservedPeerConnection>();
|
|
22
|
-
|
|
23
|
-
public updated = Date.now();
|
|
24
|
-
|
|
25
|
-
public constructor(
|
|
26
|
-
public readonly url: string,
|
|
27
|
-
public readonly observedTURN: ObservedTURN,
|
|
28
|
-
) {
|
|
29
|
-
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
public updateTurnUsage(...selectedcandidatepairs: ObservedIceCandidatePair[]) {
|
|
33
|
-
for (const selectedcandidatepair of selectedcandidatepairs) {
|
|
34
|
-
this.deltaBytesReceived += selectedcandidatepair.deltaBytesReceived;
|
|
35
|
-
this.deltaBytesSent += selectedcandidatepair.deltaBytesSent;
|
|
36
|
-
this.deltaPacketsReceived += selectedcandidatepair.deltaPacketsReceived;
|
|
37
|
-
this.deltaPacketsSent += selectedcandidatepair.deltaPacketsSent;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
public update() {
|
|
42
|
-
const now = Date.now();
|
|
43
|
-
const deltaInS = (now - this.updated) / 1000;
|
|
44
|
-
|
|
45
|
-
this.packetsSentPerSecond = this.deltaPacketsSent / deltaInS;
|
|
46
|
-
this.packetsReceivedPerSecond = this.deltaPacketsReceived / deltaInS;
|
|
47
|
-
this.outboundBitrate = (this.deltaBytesReceived * 8) / deltaInS;
|
|
48
|
-
this.inboundBitrate = (this.deltaBytesSent * 8) / deltaInS;
|
|
49
|
-
|
|
50
|
-
this.totalBytesSent += this.deltaBytesSent;
|
|
51
|
-
this.totalBytesReceived += this.deltaBytesReceived;
|
|
52
|
-
this.totalPacketsSent += this.deltaPacketsSent;
|
|
53
|
-
this.totalPacketsReceived += this.deltaPacketsReceived;
|
|
54
|
-
|
|
55
|
-
this.observedTURN.totalBytesSent += this.deltaBytesSent;
|
|
56
|
-
this.observedTURN.totalBytesReceived += this.deltaBytesReceived;
|
|
57
|
-
this.observedTURN.totalPacketsSent += this.deltaPacketsSent;
|
|
58
|
-
this.observedTURN.totalPacketsReceived += this.deltaPacketsReceived;
|
|
59
|
-
|
|
60
|
-
this.observedTURN.inboundBitrate += this.inboundBitrate;
|
|
61
|
-
this.observedTURN.outboundBitrate += this.outboundBitrate;
|
|
62
|
-
this.observedTURN.packetsReceivedPerSecond += this.packetsReceivedPerSecond;
|
|
63
|
-
this.observedTURN.packetsSentPerSecond += this.packetsSentPerSecond;
|
|
64
|
-
|
|
65
|
-
this.deltaBytesSent = 0;
|
|
66
|
-
this.deltaBytesReceived = 0;
|
|
67
|
-
this.deltaPacketsSent = 0;
|
|
68
|
-
this.deltaPacketsReceived = 0;
|
|
69
|
-
|
|
70
|
-
this.updated = now;
|
|
71
|
-
}
|
|
72
|
-
}
|
package/src/Observer.ts
DELETED
|
@@ -1,248 +0,0 @@
|
|
|
1
|
-
import { createLogger } from './common/logger';
|
|
2
|
-
import { ObservedCall, ObservedCallSettings } from './ObservedCall';
|
|
3
|
-
import { EventEmitter } from 'events';
|
|
4
|
-
import { ClientEvent, ClientMetaData, ClientIssue, ExtensionStat, ClientSample } from './schema/ClientSample';
|
|
5
|
-
import { ObservedClient } from './ObservedClient';
|
|
6
|
-
import { ObservedTURN } from './ObservedTURN';
|
|
7
|
-
import { Detectors } from './detectors/Detectors';
|
|
8
|
-
import { Updater } from './updaters/Updater';
|
|
9
|
-
import { OnIntervalUpdater } from './updaters/OnIntervalUpdater';
|
|
10
|
-
import { OnAllCallObserverUpdater } from './updaters/OnAllCallObserverUpdater';
|
|
11
|
-
import { OnAnyCallObserverUpdater } from './updaters/OnAnyCallObserverUpdater';
|
|
12
|
-
import { ObserverEventMonitor } from './ObserverEventMonitor';
|
|
13
|
-
import { MediasoupRemoteTrackResolver } from './utils/MediasoupRemoteTrackResolver';
|
|
14
|
-
|
|
15
|
-
const logger = createLogger('Observer');
|
|
16
|
-
|
|
17
|
-
export type ObserverEvents = {
|
|
18
|
-
'client-event': [ObservedClient, ClientEvent];
|
|
19
|
-
'call-updated': [ObservedCall],
|
|
20
|
-
'client-issue': [ObservedClient, ClientIssue];
|
|
21
|
-
'client-metadata': [ObservedClient, ClientMetaData];
|
|
22
|
-
'client-extension-stats': [ObservedClient, ExtensionStat];
|
|
23
|
-
'newcall': [ObservedCall],
|
|
24
|
-
'update': [],
|
|
25
|
-
'close': [],
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export type ObserverConfig<AppData extends Record<string, unknown> = Record<string, unknown>> = {
|
|
29
|
-
updatePolicy?: 'update-on-any-call-updated' | 'update-when-all-call-updated' | 'update-on-interval',
|
|
30
|
-
updateIntervalInMs?: number,
|
|
31
|
-
defaultCallUpdatePolicy?: ObservedCallSettings['updatePolicy'],
|
|
32
|
-
defaultCallUpdateIntervalInMs?: number,
|
|
33
|
-
appData?: AppData,
|
|
34
|
-
closeClientIfIdleForMs?: number,
|
|
35
|
-
closeCallIfEmptyForMs?: number,
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export declare interface Observer {
|
|
39
|
-
on<U extends keyof ObserverEvents>(event: U, listener: (...args: ObserverEvents[U]) => void): this;
|
|
40
|
-
off<U extends keyof ObserverEvents>(event: U, listener: (...args: ObserverEvents[U]) => void): this;
|
|
41
|
-
once<U extends keyof ObserverEvents>(event: U, listener: (...args: ObserverEvents[U]) => void): this;
|
|
42
|
-
emit<U extends keyof ObserverEvents>(event: U, ...args: ObserverEvents[U]): boolean;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export class Observer<AppData extends Record<string, unknown> = Record<string, unknown>> extends EventEmitter {
|
|
46
|
-
public readonly detectors: Detectors;
|
|
47
|
-
|
|
48
|
-
public readonly observedTURN = new ObservedTURN();
|
|
49
|
-
public readonly observedCalls = new Map<string, ObservedCall>();
|
|
50
|
-
public updater?: Updater;
|
|
51
|
-
|
|
52
|
-
public closed = false;
|
|
53
|
-
|
|
54
|
-
public totalAddedCall = 0;
|
|
55
|
-
public totalRemovedCall = 0;
|
|
56
|
-
|
|
57
|
-
public numberOfClientsUsingTurn = 0;
|
|
58
|
-
public numberOfClients = 0;
|
|
59
|
-
public numberOfInboundRtpStreams = 0;
|
|
60
|
-
public numberOfOutboundRtpStreams = 0;
|
|
61
|
-
public numberOfDataChannels = 0;
|
|
62
|
-
public numberOfPeerConnections = 0;
|
|
63
|
-
|
|
64
|
-
public get numberOfCalls() {
|
|
65
|
-
return this.observedCalls.size;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
private _timer?: ReturnType<typeof setInterval>;
|
|
69
|
-
|
|
70
|
-
public constructor(public readonly config: ObserverConfig<AppData> = {
|
|
71
|
-
updatePolicy: 'update-when-all-call-updated',
|
|
72
|
-
updateIntervalInMs: undefined,
|
|
73
|
-
appData: {} as AppData,
|
|
74
|
-
}) {
|
|
75
|
-
super();
|
|
76
|
-
this.setMaxListeners(Infinity);
|
|
77
|
-
this.update = this.update.bind(this);
|
|
78
|
-
|
|
79
|
-
const currentUpdatePolicy = (config?.updatePolicy) ?? 'update-when-all-call-updated';
|
|
80
|
-
|
|
81
|
-
switch (currentUpdatePolicy) {
|
|
82
|
-
case 'update-on-any-call-updated':
|
|
83
|
-
this.updater = new OnAnyCallObserverUpdater(this);
|
|
84
|
-
break;
|
|
85
|
-
case 'update-when-all-call-updated':
|
|
86
|
-
this.updater = new OnAllCallObserverUpdater(this);
|
|
87
|
-
break;
|
|
88
|
-
case 'update-on-interval': {
|
|
89
|
-
const interval = config?.updateIntervalInMs;
|
|
90
|
-
|
|
91
|
-
if (!interval) {
|
|
92
|
-
throw new Error('updateIntervalInMs setting in config must be set if updatePolicy is update-on-interval');
|
|
93
|
-
}
|
|
94
|
-
this.updater = new OnIntervalUpdater(
|
|
95
|
-
interval,
|
|
96
|
-
this.update.bind(this),
|
|
97
|
-
);
|
|
98
|
-
break;
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
this.detectors = new Detectors();
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
public get appData() {
|
|
106
|
-
return this.config.appData;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
public getObservedCall<T extends Record<string, unknown> = Record<string, unknown>>(callId: string): ObservedCall<T> | undefined {
|
|
110
|
-
if (this.closed || !this.observedCalls.has(callId)) return;
|
|
111
|
-
|
|
112
|
-
return this.observedCalls.get(callId) as ObservedCall<T>;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
public createObservedCall<T extends Record<string, unknown> = Record<string, unknown>>(
|
|
116
|
-
settings: ObservedCallSettings<T>
|
|
117
|
-
): ObservedCall<T> {
|
|
118
|
-
if (this.closed) {
|
|
119
|
-
throw new Error('Attempted to create a call source on a closed observer');
|
|
120
|
-
}
|
|
121
|
-
if (!settings.updatePolicy) {
|
|
122
|
-
settings.updatePolicy = this.config.defaultCallUpdatePolicy;
|
|
123
|
-
settings.updateIntervalInMs = this.config.defaultCallUpdateIntervalInMs;
|
|
124
|
-
}
|
|
125
|
-
if (!settings.closeCallIfEmptyForMs) {
|
|
126
|
-
settings.closeCallIfEmptyForMs = this.config.closeCallIfEmptyForMs;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
const observedCall = new ObservedCall(settings, this);
|
|
130
|
-
const onCallUpdated = () => this._onObservedCallUpdated(observedCall);
|
|
131
|
-
|
|
132
|
-
if (this.observedCalls.has(observedCall.callId)) throw new Error(`Observed Call with id ${observedCall.callId} already exists`);
|
|
133
|
-
|
|
134
|
-
if (settings.remoteTrackResolvePolicy === 'mediasoup-sfu') {
|
|
135
|
-
observedCall.remoteTrackResolver = new MediasoupRemoteTrackResolver(observedCall);
|
|
136
|
-
} else if (settings.remoteTrackResolvePolicy === 'p2p') {
|
|
137
|
-
// For future implementation
|
|
138
|
-
} else if (settings.remoteTrackResolvePolicy === 'none' || !settings.remoteTrackResolvePolicy) {
|
|
139
|
-
// do nothing
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
observedCall.once('close', () => {
|
|
143
|
-
this.observedCalls.delete(observedCall.callId);
|
|
144
|
-
observedCall.off('update', onCallUpdated);
|
|
145
|
-
++this.totalRemovedCall;
|
|
146
|
-
});
|
|
147
|
-
|
|
148
|
-
this.observedCalls.set(observedCall.callId, observedCall);
|
|
149
|
-
observedCall.on('update', onCallUpdated);
|
|
150
|
-
++this.totalAddedCall;
|
|
151
|
-
|
|
152
|
-
this.emit('newcall', observedCall);
|
|
153
|
-
|
|
154
|
-
return observedCall;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
public close() {
|
|
158
|
-
if (this.closed) {
|
|
159
|
-
return logger.debug('Attempted to close twice');
|
|
160
|
-
}
|
|
161
|
-
this.closed = true;
|
|
162
|
-
clearInterval(this._timer);
|
|
163
|
-
this._timer = undefined;
|
|
164
|
-
|
|
165
|
-
this.observedCalls.forEach((call) => call.close());
|
|
166
|
-
|
|
167
|
-
this.emit('close');
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
public accept(sample: ClientSample) {
|
|
171
|
-
if (this.closed) return;
|
|
172
|
-
if (!sample.callId) return logger.warn('Received sample without callId. %o', sample);
|
|
173
|
-
if (!sample.clientId) return logger.warn('Received sample without clientId %o', sample);
|
|
174
|
-
|
|
175
|
-
const call = this.getObservedCall(sample.callId) ?? this.createObservedCall({
|
|
176
|
-
callId: sample.callId,
|
|
177
|
-
updateIntervalInMs: this.config.defaultCallUpdateIntervalInMs,
|
|
178
|
-
updatePolicy: this.config.defaultCallUpdatePolicy,
|
|
179
|
-
});
|
|
180
|
-
|
|
181
|
-
const client = call.getObservedClient(sample.clientId) ?? call.createObservedClient({
|
|
182
|
-
clientId: sample.clientId,
|
|
183
|
-
});
|
|
184
|
-
|
|
185
|
-
client.accept(sample);
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
public update() {
|
|
189
|
-
if (this.closed) {
|
|
190
|
-
return;
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
this.numberOfInboundRtpStreams = 0;
|
|
194
|
-
this.numberOfOutboundRtpStreams = 0;
|
|
195
|
-
this.numberOfPeerConnections = 0;
|
|
196
|
-
this.numberOfDataChannels = 0;
|
|
197
|
-
this.numberOfClients = 0;
|
|
198
|
-
this.numberOfClientsUsingTurn = 0;
|
|
199
|
-
|
|
200
|
-
for (const call of this.observedCalls.values()) {
|
|
201
|
-
this.numberOfInboundRtpStreams += call.numberOfInboundRtpStreams;
|
|
202
|
-
this.numberOfOutboundRtpStreams += call.numberOfOutboundRtpStreams;
|
|
203
|
-
this.numberOfPeerConnections += call.numberOfPeerConnections;
|
|
204
|
-
this.numberOfDataChannels += call.numberOfDataChannels;
|
|
205
|
-
this.numberOfClients += call.numberOfClients;
|
|
206
|
-
this.numberOfClientsUsingTurn += call.clientsUsedTurn.size;
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
this.observedTURN.update();
|
|
210
|
-
|
|
211
|
-
this.emit('update');
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
private _onObservedCallUpdated(call: ObservedCall) {
|
|
215
|
-
call;
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
public createEventMonitor<CTX = unknown>(ctx?: CTX): ObserverEventMonitor<CTX> {
|
|
219
|
-
return new ObserverEventMonitor<CTX>(this, ctx ?? {} as CTX);
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
// public resetSummaryMetrics() {
|
|
223
|
-
// this.totalAddedCall = 0;
|
|
224
|
-
// this.totalRemovedCall = 0;
|
|
225
|
-
// this.totalRttLt50Measurements = 0;
|
|
226
|
-
// this.totalRttLt150Measurements = 0;
|
|
227
|
-
// this.totalRttLt300Measurements = 0;
|
|
228
|
-
// this.totalRttGtOrEq300Measurements = 0;
|
|
229
|
-
// this.totalClientIssues = 0;
|
|
230
|
-
// }
|
|
231
|
-
|
|
232
|
-
// public createSummary(): ObserverSummary {
|
|
233
|
-
// return {
|
|
234
|
-
// totalAddedCall: this.totalAddedCall,
|
|
235
|
-
// totalRemovedCall: this.totalRemovedCall,
|
|
236
|
-
// totalRttLt50Measurements: this.totalRttLt50Measurements,
|
|
237
|
-
// totalRttLt150Measurements: this.totalRttLt150Measurements,
|
|
238
|
-
// totalRttLt300Measurements: this.totalRttLt300Measurements,
|
|
239
|
-
// totalRttGtOrEq300Measurements: this.totalRttGtOrEq300Measurements,
|
|
240
|
-
|
|
241
|
-
// totalClientIssues: this.totalClientIssues,
|
|
242
|
-
// currentActiveCalls: this.observedCalls.size,
|
|
243
|
-
// currentNumberOfClients: this.numberOfClients,
|
|
244
|
-
// currentNumberOfClientsUsingTURN: this.numberOfClientsUsedTurn,
|
|
245
|
-
// };
|
|
246
|
-
// }
|
|
247
|
-
|
|
248
|
-
}
|