@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/common/utils.ts
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
export type PartialBy<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
|
|
2
|
-
|
|
3
|
-
export type Writable<T> = T extends object ? { -readonly [K in keyof T]: Writable<T[K]> } : T;
|
|
4
|
-
|
|
5
|
-
export function iteratorConverter<T>(generator: Generator<T, void, undefined>): IterableIterator<T> {
|
|
6
|
-
return {
|
|
7
|
-
[Symbol.iterator](): IterableIterator<T> {
|
|
8
|
-
return this;
|
|
9
|
-
},
|
|
10
|
-
next(): IteratorResult<T> {
|
|
11
|
-
return generator.next();
|
|
12
|
-
},
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export function asyncIteratorConverter<T>(generator: AsyncGenerator<T, void, undefined>): AsyncIterableIterator<T> {
|
|
17
|
-
return {
|
|
18
|
-
[Symbol.asyncIterator](): AsyncIterableIterator<T> {
|
|
19
|
-
return this;
|
|
20
|
-
},
|
|
21
|
-
next(): Promise<IteratorResult<T>> {
|
|
22
|
-
return generator.next();
|
|
23
|
-
},
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export function isValidUuid(str: string): boolean {
|
|
28
|
-
const regexp = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-5][0-9a-f]{3}-[089ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
|
29
|
-
|
|
30
|
-
return regexp.test(str);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export function getMedian(arr: number[]): number {
|
|
34
|
-
// Sort the array in ascending order
|
|
35
|
-
const sortedArr = arr.slice().sort((a, b) => a - b);
|
|
36
|
-
|
|
37
|
-
// Calculate the middle index
|
|
38
|
-
const mid = Math.floor(sortedArr.length / 2);
|
|
39
|
-
|
|
40
|
-
// If the array length is odd, return the middle element
|
|
41
|
-
if (sortedArr.length % 2 !== 0) {
|
|
42
|
-
return sortedArr[mid];
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
// If the array length is even, return the average of the two middle elements
|
|
46
|
-
return (sortedArr[mid - 1] + sortedArr[mid]) / 2;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export function parseJsonAs<T>(json?: string): T | undefined {
|
|
50
|
-
if (!json) {
|
|
51
|
-
return undefined;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
try {
|
|
55
|
-
return JSON.parse(json) as T;
|
|
56
|
-
} catch (error) {
|
|
57
|
-
return undefined;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { createLogger } from '../common/logger';
|
|
2
|
-
import { Detector } from './Detector';
|
|
3
|
-
|
|
4
|
-
const logger = createLogger('Detectors');
|
|
5
|
-
|
|
6
|
-
export class Detectors {
|
|
7
|
-
private _detectors: Detector[];
|
|
8
|
-
|
|
9
|
-
public constructor(...detectors: Detector[]) {
|
|
10
|
-
this._detectors = detectors;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
public add(detector: Detector) {
|
|
14
|
-
this._detectors.push(detector);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
public remove(detector: Detector) {
|
|
18
|
-
this._detectors = this._detectors.filter((d) => d !== detector);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
get listOfNames() {
|
|
22
|
-
return this._detectors.map((d) => d.name);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
public update() {
|
|
26
|
-
for (const detector of this._detectors) {
|
|
27
|
-
try {
|
|
28
|
-
detector.update();
|
|
29
|
-
} catch (err) {
|
|
30
|
-
logger.warn(`Error updating detector ${detector?.constructor?.name}`, err);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
public clear() {
|
|
36
|
-
this._detectors = [];
|
|
37
|
-
}
|
|
38
|
-
}
|
package/src/index.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
export type { ObserverEvents } from './Observer';
|
|
2
|
-
|
|
3
|
-
export { Observer } from './Observer';
|
|
4
|
-
export { ObservedCall } from './ObservedCall';
|
|
5
|
-
export { ObservedInboundTrack } from './ObservedInboundTrack';
|
|
6
|
-
export { ObservedOutboundTrack } from './ObservedOutboundTrack';
|
|
7
|
-
export { ObservedClient } from './ObservedClient';
|
|
8
|
-
export { ObservedPeerConnection } from './ObservedPeerConnection';
|
|
9
|
-
export { ObservedMediaSource } from './ObservedMediaSource';
|
|
10
|
-
export { ObservedMediaPlayout } from './ObservedMediaPlayout';
|
|
11
|
-
export { ObservedCodec } from './ObservedCodec';
|
|
12
|
-
export { ObservedCertificate } from './ObservedCertificate';
|
|
13
|
-
export { ObservedDataChannel } from './ObservedDataChannel';
|
|
14
|
-
export { ObservedInboundRtp } from './ObservedInboundRtp';
|
|
15
|
-
export { ObservedOutboundRtp } from './ObservedOutboundRtp';
|
|
16
|
-
export { ObservedRemoteInboundRtp } from './ObservedRemoteInboundRtp';
|
|
17
|
-
export { ObservedRemoteOutboundRtp } from './ObservedRemoteOutboundRtp';
|
|
18
|
-
export { ObservedIceCandidatePair } from './ObservedIceCandidatePair';
|
|
19
|
-
export { ObservedIceCandidate } from './ObservedIceCandidate';
|
|
20
|
-
export { ObservedIceTransport } from './ObservedIceTransport';
|
|
21
|
-
export { ObservedPeerConnectionTransport } from './ObservedPeerConnectionTransport';
|
|
22
|
-
export type { ClientEventTypes } from './schema/ClientEventTypes';
|
|
23
|
-
export type { ClientMetaTypes } from './schema/ClientMetaTypes';
|
|
24
|
-
export type { ClientSample } from './schema/ClientSample';
|
|
25
|
-
export { ScoreCalculator } from './scores/ScoreCalculator';
|
|
26
|
-
|
|
27
|
-
export { Middleware } from './common/Middleware';
|
|
@@ -1,187 +0,0 @@
|
|
|
1
|
-
// import { EventEmitter } from 'events';
|
|
2
|
-
// import { ObservedPeerConnection } from '../ObservedPeerConnection';
|
|
3
|
-
// import { ObservedICEEvents } from '../ObservedICE';
|
|
4
|
-
// import { ObservedClient } from '../ObservedClient';
|
|
5
|
-
|
|
6
|
-
// export type TurnUsageMonitorEvents = {
|
|
7
|
-
// close: [],
|
|
8
|
-
// 'newturnip': [string],
|
|
9
|
-
// update: [TurnUsage],
|
|
10
|
-
// addpeerconnection: [ObservedPeerConnection],
|
|
11
|
-
// removepeerconnection: [ObservedPeerConnection],
|
|
12
|
-
// }
|
|
13
|
-
|
|
14
|
-
// export type TurnUsage = {
|
|
15
|
-
// turnIp: string;
|
|
16
|
-
// totalBytesSent: number;
|
|
17
|
-
// totalBytesReceived: number;
|
|
18
|
-
// totalPacketsSent: number;
|
|
19
|
-
// totalPacketsReceived: number;
|
|
20
|
-
// }
|
|
21
|
-
|
|
22
|
-
// export type TurnStats = {
|
|
23
|
-
// turnIp: string;
|
|
24
|
-
// totalBytesSent: number;
|
|
25
|
-
// totalBytesReceived: number;
|
|
26
|
-
// totalPacketsSent: number;
|
|
27
|
-
// totalPacketsReceived: number;
|
|
28
|
-
// deltaBytesSent: number;
|
|
29
|
-
// deltaBytesReceived: number;
|
|
30
|
-
// timestamp: number;
|
|
31
|
-
// outboundBitrate: number;
|
|
32
|
-
// inboundBitrate: number;
|
|
33
|
-
// }
|
|
34
|
-
|
|
35
|
-
// type ObservedConnection = {
|
|
36
|
-
// peerConnection: ObservedPeerConnection,
|
|
37
|
-
// onUpdate: (...e: ObservedICEEvents['update']) => void;
|
|
38
|
-
|
|
39
|
-
// }
|
|
40
|
-
|
|
41
|
-
// export declare interface TurnUsageMonitor {
|
|
42
|
-
// on<U extends keyof TurnUsageMonitorEvents>(event: U, listener: (...args: TurnUsageMonitorEvents[U]) => void): this;
|
|
43
|
-
// off<U extends keyof TurnUsageMonitorEvents>(event: U, listener: (...args: TurnUsageMonitorEvents[U]) => void): this;
|
|
44
|
-
// once<U extends keyof TurnUsageMonitorEvents>(event: U, listener: (...args: TurnUsageMonitorEvents[U]) => void): this;
|
|
45
|
-
// emit<U extends keyof TurnUsageMonitorEvents>(event: U, ...args: TurnUsageMonitorEvents[U]): boolean;
|
|
46
|
-
// }
|
|
47
|
-
|
|
48
|
-
// export class TurnUsageMonitor extends EventEmitter {
|
|
49
|
-
// private readonly _connections = new Map<string, ObservedConnection>();
|
|
50
|
-
// private readonly _turnUsage = new Map<string, TurnUsage>();
|
|
51
|
-
// private readonly _stats = new Map<string, TurnStats>();
|
|
52
|
-
|
|
53
|
-
// private _closed = false;
|
|
54
|
-
// public constructor() {
|
|
55
|
-
// super();
|
|
56
|
-
// this.setMaxListeners(Infinity);
|
|
57
|
-
// }
|
|
58
|
-
|
|
59
|
-
// public get stats(): TurnStats[] {
|
|
60
|
-
// const result: TurnStats[] = [];
|
|
61
|
-
|
|
62
|
-
// for (const [ turnIp, usage ] of this._turnUsage) {
|
|
63
|
-
// const stats = this._stats.get(turnIp) ?? {
|
|
64
|
-
// turnIp,
|
|
65
|
-
// totalBytesSent: 0,
|
|
66
|
-
// totalBytesReceived: 0,
|
|
67
|
-
// totalPacketsSent: 0,
|
|
68
|
-
// totalPacketsReceived: 0,
|
|
69
|
-
// deltaBytesSent: 0,
|
|
70
|
-
// deltaBytesReceived: 0,
|
|
71
|
-
// timestamp: Date.now(),
|
|
72
|
-
// outboundBitrate: 0,
|
|
73
|
-
// inboundBitrate: 0,
|
|
74
|
-
// };
|
|
75
|
-
|
|
76
|
-
// stats.deltaBytesSent = usage.totalBytesSent - stats.totalBytesSent;
|
|
77
|
-
// stats.deltaBytesReceived = usage.totalBytesReceived - stats.totalBytesReceived;
|
|
78
|
-
// stats.timestamp = Date.now();
|
|
79
|
-
// stats.outboundBitrate = (stats.deltaBytesSent * 8) / ((stats.timestamp - stats.timestamp) / 1000.0);
|
|
80
|
-
// stats.inboundBitrate = (stats.deltaBytesReceived * 8) / ((stats.timestamp - stats.timestamp) / 1000.0);
|
|
81
|
-
// stats.totalBytesSent = usage.totalBytesSent;
|
|
82
|
-
// stats.totalBytesReceived = usage.totalBytesReceived;
|
|
83
|
-
// stats.totalPacketsSent = usage.totalPacketsSent;
|
|
84
|
-
// stats.totalPacketsReceived = usage.totalPacketsReceived;
|
|
85
|
-
|
|
86
|
-
// this._stats.set(turnIp, stats);
|
|
87
|
-
|
|
88
|
-
// result.push(stats);
|
|
89
|
-
// }
|
|
90
|
-
|
|
91
|
-
// return result;
|
|
92
|
-
// }
|
|
93
|
-
|
|
94
|
-
// public addPeerConnection(peerConnection: ObservedPeerConnection) {
|
|
95
|
-
// if (this.closed) return;
|
|
96
|
-
// if (this._connections.has(peerConnection.peerConnectionId)) return;
|
|
97
|
-
|
|
98
|
-
// const ice = peerConnection.ICE;
|
|
99
|
-
|
|
100
|
-
// const onUpdate = () => {
|
|
101
|
-
// const turnIp = ice?.selectedRemoteCandidate?.address;
|
|
102
|
-
|
|
103
|
-
// if (!peerConnection.usingTURN || !turnIp) return;
|
|
104
|
-
|
|
105
|
-
// let usage = this._turnUsage.get(turnIp);
|
|
106
|
-
|
|
107
|
-
// if (!usage) {
|
|
108
|
-
// usage = {
|
|
109
|
-
// turnIp,
|
|
110
|
-
// totalBytesSent: 0,
|
|
111
|
-
// totalBytesReceived: 0,
|
|
112
|
-
// totalPacketsSent: 0,
|
|
113
|
-
// totalPacketsReceived: 0,
|
|
114
|
-
// };
|
|
115
|
-
// this._turnUsage.set(turnIp, usage);
|
|
116
|
-
|
|
117
|
-
// this.emit('newturnip', turnIp);
|
|
118
|
-
// }
|
|
119
|
-
|
|
120
|
-
// usage.totalBytesSent += ice.deltaBytesSent;
|
|
121
|
-
// usage.totalBytesReceived += ice.deltaBytesReceived;
|
|
122
|
-
// usage.totalPacketsSent += ice.deltaPacketsSent;
|
|
123
|
-
// usage.totalPacketsReceived += ice.deltaPacketsReceived;
|
|
124
|
-
|
|
125
|
-
// this.emit('update', usage);
|
|
126
|
-
// };
|
|
127
|
-
|
|
128
|
-
// peerConnection.ICE.on('update', onUpdate);
|
|
129
|
-
|
|
130
|
-
// this._connections.set(peerConnection.peerConnectionId, {
|
|
131
|
-
// peerConnection,
|
|
132
|
-
// onUpdate
|
|
133
|
-
// });
|
|
134
|
-
|
|
135
|
-
// this.emit('addpeerconnection', peerConnection);
|
|
136
|
-
// }
|
|
137
|
-
|
|
138
|
-
// public removePeerConnection(peerConnection: ObservedPeerConnection) {
|
|
139
|
-
// if (this.closed) return;
|
|
140
|
-
// if (!this._connections.has(peerConnection.peerConnectionId)) return;
|
|
141
|
-
|
|
142
|
-
// const { onUpdate } = this._connections.get(peerConnection.peerConnectionId) ?? {};
|
|
143
|
-
|
|
144
|
-
// if (!onUpdate) return;
|
|
145
|
-
|
|
146
|
-
// peerConnection.ICE.off('update', onUpdate);
|
|
147
|
-
|
|
148
|
-
// this._connections.delete(peerConnection.peerConnectionId);
|
|
149
|
-
|
|
150
|
-
// this.emit('removepeerconnection', peerConnection);
|
|
151
|
-
// }
|
|
152
|
-
|
|
153
|
-
// public get turnIps() {
|
|
154
|
-
// return Array.from(this._turnUsage.keys());
|
|
155
|
-
// }
|
|
156
|
-
|
|
157
|
-
// public get peerConnections() {
|
|
158
|
-
// return Array.from(this._connections.values()).map(({ peerConnection }) => peerConnection);
|
|
159
|
-
// }
|
|
160
|
-
|
|
161
|
-
// public getUsage(turnIp: string) {
|
|
162
|
-
// return this._turnUsage.get(turnIp);
|
|
163
|
-
// }
|
|
164
|
-
|
|
165
|
-
// public get clients(): ReadonlyMap<string, ObservedClient> {
|
|
166
|
-
// const result = new Map<string, ObservedClient>();
|
|
167
|
-
|
|
168
|
-
// for (const pc of this.peerConnections) {
|
|
169
|
-
// if (result.has(pc.clientId)) continue;
|
|
170
|
-
|
|
171
|
-
// result.set(pc.clientId, pc.client);
|
|
172
|
-
// }
|
|
173
|
-
|
|
174
|
-
// return result;
|
|
175
|
-
// }
|
|
176
|
-
|
|
177
|
-
// public get closed() {
|
|
178
|
-
// return this._closed;
|
|
179
|
-
// }
|
|
180
|
-
|
|
181
|
-
// public close() {
|
|
182
|
-
// if (this._closed) return;
|
|
183
|
-
// this._closed = true;
|
|
184
|
-
|
|
185
|
-
// this.emit('close');
|
|
186
|
-
// }
|
|
187
|
-
// }
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
/* eslint-disable no-shadow */
|
|
2
|
-
|
|
3
|
-
export enum ClientEventTypes {
|
|
4
|
-
CALL_STARTED = 'CALL_STARTED',
|
|
5
|
-
CALL_ENDED = 'CALL_ENDED',
|
|
6
|
-
CLIENT_JOINED = 'CLIENT_JOINED',
|
|
7
|
-
CLIENT_LEFT = 'CLIENT_LEFT',
|
|
8
|
-
PEER_CONNECTION_OPENED = 'PEER_CONNECTION_OPENED',
|
|
9
|
-
PEER_CONNECTION_CLOSED = 'PEER_CONNECTION_CLOSED',
|
|
10
|
-
MEDIA_TRACK_ADDED = 'MEDIA_TRACK_ADDED',
|
|
11
|
-
MEDIA_TRACK_REMOVED = 'MEDIA_TRACK_REMOVED',
|
|
12
|
-
MEDIA_TRACK_RESUMED = 'MEDIA_TRACK_RESUMED',
|
|
13
|
-
MEDIA_TRACK_MUTED = 'MEDIA_TRACK_MUTED',
|
|
14
|
-
MEDIA_TRACK_UNMUTED = 'MEDIA_TRACK_UNMUTED',
|
|
15
|
-
ICE_GATHERING_STATE_CHANGED = 'ICE_GATHERING_STATE_CHANGED',
|
|
16
|
-
PEER_CONNECTION_STATE_CHANGED = 'PEER_CONNECTION_STATE_CHANGED',
|
|
17
|
-
ICE_CONNECTION_STATE_CHANGED = 'ICE_CONNECTION_STATE_CHANGED',
|
|
18
|
-
DATA_CHANNEL_OPEN = 'DATA_CHANNEL_OPEN',
|
|
19
|
-
DATA_CHANNEL_CLOSED = 'DATA_CHANNEL_CLOSED',
|
|
20
|
-
DATA_CHANNEL_ERROR = 'DATA_CHANNEL_ERROR',
|
|
21
|
-
NEGOTIATION_NEEDED = 'NEGOTIATION_NEEDED',
|
|
22
|
-
SIGNALING_STATE_CHANGE = 'SIGNALING_STATE_CHANGE',
|
|
23
|
-
ICE_GATHERING_STATE_CHANGE = 'ICE_GATHERING_STATE_CHANGE',
|
|
24
|
-
ICE_CONNECTION_STATE_CHANGE = 'ICE_CONNECTION_STATE_CHANGE',
|
|
25
|
-
ICE_CANDIDATE = 'ICE_CANDIDATE',
|
|
26
|
-
|
|
27
|
-
// mediasoup events
|
|
28
|
-
PRODUCER_ADDED = 'PRODUCER_ADDED',
|
|
29
|
-
PRODUCER_REMOVED = 'PRODUCER_REMOVED',
|
|
30
|
-
CONSUMER_ADDED = 'CONSUMER_ADDED',
|
|
31
|
-
CONSUMER_REMOVED = 'CONSUMER_REMOVED',
|
|
32
|
-
DATA_PRODUCER_CREATED = 'DATA_PRODUCER_CREATED',
|
|
33
|
-
DATA_PRODUCER_CLOSED = 'DATA_PRODUCER_CLOSED',
|
|
34
|
-
DATA_CONSUMER_CREATED = 'DATA_CONSUMER_CREATED',
|
|
35
|
-
DATA_CONSUMER_CLOSED = 'DATA_CONSUMER_CLOSED',
|
|
36
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
/* eslint-disable no-shadow */
|
|
2
|
-
|
|
3
|
-
export enum ClientMetaTypes {
|
|
4
|
-
MEDIA_CONSTRAINT = 'MEDIA_CONSTRAINT',
|
|
5
|
-
MEDIA_DEVICE = 'MEDIA_DEVICE',
|
|
6
|
-
MEDIA_DEVICES_SUPPORTED_CONSTRAINTS = 'MEDIA_DEVICES_SUPPORTED_CONSTRAINTS',
|
|
7
|
-
USER_MEDIA_ERROR = 'USER_MEDIA_ERROR',
|
|
8
|
-
LOCAL_SDP = 'LOCAL_SDP',
|
|
9
|
-
|
|
10
|
-
OPERATION_SYSTEM = 'OPERATION_SYSTEM',
|
|
11
|
-
ENGINE = 'ENGINE',
|
|
12
|
-
PLATFORM = 'PLATFORM',
|
|
13
|
-
BROWSER = 'BROWSER',
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export type MediaDeviceInfo = {
|
|
17
|
-
deviceId: string;
|
|
18
|
-
label: string;
|
|
19
|
-
kind: string;
|
|
20
|
-
groupId: string;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export type Browser = {
|
|
24
|
-
name: string;
|
|
25
|
-
version: string;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export type Platform = {
|
|
29
|
-
name: string;
|
|
30
|
-
version: string;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export type Engine = {
|
|
34
|
-
name: string;
|
|
35
|
-
version: string;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export type OperationSystem = {
|
|
39
|
-
name: string;
|
|
40
|
-
version: string;
|
|
41
|
-
}
|