@voicenter-team/opensips-js 1.0.22 → 1.0.45
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/index.d.ts +732 -0
- package/dist/opensips-js.cjs.js +155 -0
- package/dist/opensips-js.es.js +21367 -0
- package/dist/opensips-js.iife.js +155 -0
- package/dist/opensips-js.umd.js +155 -0
- package/package.json +14 -8
- package/src/types/Dialog.d.ts +7 -0
- package/src/types/Socket.d.ts +8 -0
- package/src/types/UAExtended.d.ts +22 -14
- package/src/types/listeners.d.ts +12 -4
- package/src/types/msrp.d.ts +15 -9
- package/src/types/rtc.d.ts +15 -5
- package/src/types/timer.d.ts +7 -0
- package/build/enum/call.event.listener.type.d.ts +0 -7
- package/build/enum/call.event.listener.type.js +0 -10
- package/build/enum/message.event.listener.type.d.ts +0 -5
- package/build/enum/message.event.listener.type.js +0 -8
- package/build/enum/metric.keys.to.include.d.ts +0 -2
- package/build/enum/metric.keys.to.include.js +0 -4
- package/build/enum/session.direction.enum.d.ts +0 -2
- package/build/enum/session.direction.enum.js +0 -5
- package/build/helpers/UA/index.d.ts +0 -41
- package/build/helpers/UA/index.js +0 -318
- package/build/helpers/audio.helper.d.ts +0 -15
- package/build/helpers/audio.helper.js +0 -97
- package/build/helpers/filter.helper.d.ts +0 -2
- package/build/helpers/filter.helper.js +0 -14
- package/build/helpers/jssip.d.ts +0 -5
- package/build/helpers/jssip.js +0 -30
- package/build/helpers/time.helper.d.ts +0 -16
- package/build/helpers/time.helper.js +0 -28
- package/build/helpers/volume.helper.d.ts +0 -2
- package/build/helpers/volume.helper.js +0 -76
- package/build/helpers/webrtcmetrics/collector.d.ts +0 -32
- package/build/helpers/webrtcmetrics/collector.js +0 -282
- package/build/helpers/webrtcmetrics/engine.d.ts +0 -20
- package/build/helpers/webrtcmetrics/engine.js +0 -164
- package/build/helpers/webrtcmetrics/exporter.d.ts +0 -116
- package/build/helpers/webrtcmetrics/exporter.js +0 -528
- package/build/helpers/webrtcmetrics/extractor.d.ts +0 -1
- package/build/helpers/webrtcmetrics/extractor.js +0 -976
- package/build/helpers/webrtcmetrics/index.d.ts +0 -63
- package/build/helpers/webrtcmetrics/index.js +0 -93
- package/build/helpers/webrtcmetrics/metrics.d.ts +0 -2
- package/build/helpers/webrtcmetrics/metrics.js +0 -8
- package/build/helpers/webrtcmetrics/probe.d.ts +0 -76
- package/build/helpers/webrtcmetrics/probe.js +0 -153
- package/build/helpers/webrtcmetrics/utils/config.d.ts +0 -12
- package/build/helpers/webrtcmetrics/utils/config.js +0 -28
- package/build/helpers/webrtcmetrics/utils/helper.d.ts +0 -13
- package/build/helpers/webrtcmetrics/utils/helper.js +0 -134
- package/build/helpers/webrtcmetrics/utils/log.d.ts +0 -7
- package/build/helpers/webrtcmetrics/utils/log.js +0 -71
- package/build/helpers/webrtcmetrics/utils/models.d.ts +0 -309
- package/build/helpers/webrtcmetrics/utils/models.js +0 -298
- package/build/helpers/webrtcmetrics/utils/score.d.ts +0 -4
- package/build/helpers/webrtcmetrics/utils/score.js +0 -235
- package/build/helpers/webrtcmetrics/utils/shortUUId.d.ts +0 -1
- package/build/helpers/webrtcmetrics/utils/shortUUId.js +0 -7
- package/build/index.d.ts +0 -180
- package/build/index.js +0 -1141
- package/build/lib/msrp/message.d.ts +0 -12
- package/build/lib/msrp/message.js +0 -82
- package/build/lib/msrp/session.d.ts +0 -94
- package/build/lib/msrp/session.js +0 -621
@@ -1,282 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9
|
-
});
|
10
|
-
};
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
13
|
-
};
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
15
|
-
const exporter_1 = __importDefault(require("./exporter"));
|
16
|
-
const extractor_1 = require("./extractor");
|
17
|
-
const score_1 = require("./utils/score");
|
18
|
-
const models_1 = require("./utils/models");
|
19
|
-
const helper_1 = require("./utils/helper");
|
20
|
-
const log_1 = require("./utils/log");
|
21
|
-
class Collector {
|
22
|
-
constructor(cfg, refProbeId) {
|
23
|
-
this._callbacks = {
|
24
|
-
onreport: null,
|
25
|
-
onticket: null,
|
26
|
-
};
|
27
|
-
this._id = (0, helper_1.createCollectorId)();
|
28
|
-
this._moduleName = this._id;
|
29
|
-
this._probeId = refProbeId;
|
30
|
-
this._config = cfg;
|
31
|
-
this._exporter = new exporter_1.default(cfg);
|
32
|
-
this._state = models_1.COLLECTOR_STATE.IDLE;
|
33
|
-
this.registerToPCEvents();
|
34
|
-
(0, log_1.info)(this._moduleName, `new collector created for probe ${this._probeId}`);
|
35
|
-
}
|
36
|
-
analyze(stats, previousReport, beforeLastReport, referenceReport) {
|
37
|
-
const getDefaultSSRCMetric = (kind, reportType) => {
|
38
|
-
if (kind === models_1.VALUE.AUDIO) {
|
39
|
-
if (reportType === models_1.TYPE.INBOUND_RTP) {
|
40
|
-
return Object.assign({}, models_1.defaultAudioMetricIn);
|
41
|
-
}
|
42
|
-
return Object.assign({}, models_1.defaultAudioMetricOut);
|
43
|
-
}
|
44
|
-
if (reportType === models_1.TYPE.INBOUND_RTP) {
|
45
|
-
return Object.assign({}, models_1.defaultVideoMetricIn);
|
46
|
-
}
|
47
|
-
return Object.assign({}, models_1.defaultVideoMetricOut);
|
48
|
-
};
|
49
|
-
const report = (0, models_1.getDefaultMetric)(previousReport);
|
50
|
-
report.pname = this._config.pname;
|
51
|
-
report.call_id = this._config.cid;
|
52
|
-
report.user_id = this._config.uid;
|
53
|
-
report.count = previousReport ? previousReport.count + 1 : 1;
|
54
|
-
let timestamp = null;
|
55
|
-
stats.forEach((stat) => {
|
56
|
-
if (!timestamp && stat.timestamp) {
|
57
|
-
timestamp = stat.timestamp;
|
58
|
-
}
|
59
|
-
const values = (0, extractor_1.extract)(stat, report, report.pname, referenceReport);
|
60
|
-
values.forEach((data) => {
|
61
|
-
if (data.value && data.type) {
|
62
|
-
if (data.ssrc) {
|
63
|
-
let ssrcReport = report[data.type][data.ssrc];
|
64
|
-
if (!ssrcReport) {
|
65
|
-
ssrcReport = getDefaultSSRCMetric(data.type, stat.type);
|
66
|
-
ssrcReport.ssrc = data.ssrc;
|
67
|
-
report[data.type][data.ssrc] = (ssrcReport);
|
68
|
-
}
|
69
|
-
Object.keys(data.value).forEach((key) => {
|
70
|
-
ssrcReport[key] = data.value[key];
|
71
|
-
});
|
72
|
-
}
|
73
|
-
else {
|
74
|
-
Object.keys(data.value).forEach((key) => {
|
75
|
-
report[data.type][key] = data.value[key];
|
76
|
-
});
|
77
|
-
}
|
78
|
-
}
|
79
|
-
});
|
80
|
-
});
|
81
|
-
report.timestamp = timestamp;
|
82
|
-
Object.keys(report[models_1.VALUE.AUDIO]).forEach((key) => {
|
83
|
-
const ssrcReport = report[models_1.VALUE.AUDIO][key];
|
84
|
-
if (ssrcReport.direction === models_1.DIRECTION.INBOUND) {
|
85
|
-
ssrcReport.mos_emodel_in = (0, score_1.computeEModelMOS)(report, models_1.VALUE.AUDIO, previousReport, beforeLastReport, ssrcReport.ssrc);
|
86
|
-
ssrcReport.mos_in = (0, score_1.computeMOS)(report, models_1.VALUE.AUDIO, previousReport, beforeLastReport, ssrcReport.ssrc);
|
87
|
-
}
|
88
|
-
else {
|
89
|
-
ssrcReport.mos_emodel_out = (0, score_1.computeEModelMOSForOutgoing)(report, models_1.VALUE.AUDIO, previousReport, beforeLastReport, ssrcReport.ssrc);
|
90
|
-
ssrcReport.mos_out = (0, score_1.computeMOSForOutgoing)(report, models_1.VALUE.AUDIO, previousReport, beforeLastReport, ssrcReport.ssrc);
|
91
|
-
}
|
92
|
-
});
|
93
|
-
return report;
|
94
|
-
}
|
95
|
-
takeReferenceStats() {
|
96
|
-
return __awaiter(this, void 0, void 0, function* () {
|
97
|
-
return new Promise((resolve, reject) => {
|
98
|
-
const preWaitTime = Date.now();
|
99
|
-
setTimeout(() => __awaiter(this, void 0, void 0, function* () {
|
100
|
-
try {
|
101
|
-
const waitTime = Date.now() - preWaitTime;
|
102
|
-
const preTime = Date.now();
|
103
|
-
const reports = yield this._config.pc.getStats();
|
104
|
-
const referenceReport = this.analyze(reports, null, null, null);
|
105
|
-
const postTime = Date.now();
|
106
|
-
referenceReport.experimental.time_to_measure_ms = postTime - preTime;
|
107
|
-
referenceReport.experimental.time_to_wait_ms = waitTime;
|
108
|
-
this._exporter.saveReferenceReport(referenceReport);
|
109
|
-
(0, log_1.debug)(this._moduleName, `got reference report for probe ${this._probeId}`);
|
110
|
-
resolve();
|
111
|
-
}
|
112
|
-
catch (err) {
|
113
|
-
reject(err);
|
114
|
-
}
|
115
|
-
}), this._config.startAfter);
|
116
|
-
});
|
117
|
-
});
|
118
|
-
}
|
119
|
-
collectStats() {
|
120
|
-
return __awaiter(this, void 0, void 0, function* () {
|
121
|
-
try {
|
122
|
-
if (this._state !== models_1.COLLECTOR_STATE.RUNNING || !this._config.pc) {
|
123
|
-
(0, log_1.debug)(this._moduleName, `report discarded (too late) for probe ${this._probeId}`);
|
124
|
-
return null;
|
125
|
-
}
|
126
|
-
// Take into account last report in case no report have been generated (eg: candidate-pair)
|
127
|
-
const preTime = Date.now();
|
128
|
-
const reports = yield this._config.pc.getStats();
|
129
|
-
const report = this.analyze(reports, this._exporter.getLastReport(), this._exporter.getBeforeLastReport(), this._exporter.getReferenceReport());
|
130
|
-
const postTime = Date.now();
|
131
|
-
report.experimental.time_to_measure_ms = postTime - preTime;
|
132
|
-
this._exporter.addReport(report);
|
133
|
-
(0, log_1.debug)(this._moduleName, `got report for probe ${this._probeId}#${this._exporter.getReportsNumber() + 1}`);
|
134
|
-
this.fireOnReport(report);
|
135
|
-
return report;
|
136
|
-
}
|
137
|
-
catch (err) {
|
138
|
-
(0, log_1.error)(this._moduleName, `got error ${err}`);
|
139
|
-
return null;
|
140
|
-
}
|
141
|
-
});
|
142
|
-
}
|
143
|
-
start() {
|
144
|
-
return __awaiter(this, void 0, void 0, function* () {
|
145
|
-
(0, log_1.debug)(this._moduleName, "starting");
|
146
|
-
this.state = models_1.COLLECTOR_STATE.RUNNING;
|
147
|
-
this._startedTime = this._exporter.start();
|
148
|
-
(0, log_1.debug)(this._moduleName, "started");
|
149
|
-
});
|
150
|
-
}
|
151
|
-
mute() {
|
152
|
-
return __awaiter(this, void 0, void 0, function* () {
|
153
|
-
this.state = models_1.COLLECTOR_STATE.MUTED;
|
154
|
-
(0, log_1.debug)(this._moduleName, "muted");
|
155
|
-
});
|
156
|
-
}
|
157
|
-
unmute() {
|
158
|
-
return __awaiter(this, void 0, void 0, function* () {
|
159
|
-
this.state = models_1.COLLECTOR_STATE.RUNNING;
|
160
|
-
(0, log_1.debug)(this._moduleName, "unmuted");
|
161
|
-
});
|
162
|
-
}
|
163
|
-
stop(forced) {
|
164
|
-
return __awaiter(this, void 0, void 0, function* () {
|
165
|
-
(0, log_1.debug)(this._moduleName, `stopping${forced ? " by watchdog" : ""}...`);
|
166
|
-
this._stoppedTime = this._exporter.stop();
|
167
|
-
this.state = models_1.COLLECTOR_STATE.IDLE;
|
168
|
-
if (this._config.ticket) {
|
169
|
-
const { ticket } = this._exporter;
|
170
|
-
this.fireOnTicket(ticket);
|
171
|
-
}
|
172
|
-
this._exporter.reset();
|
173
|
-
(0, log_1.debug)(this._moduleName, "stopped");
|
174
|
-
});
|
175
|
-
}
|
176
|
-
registerCallback(name, callback, context) {
|
177
|
-
if (name in this._callbacks) {
|
178
|
-
this._callbacks[name] = {
|
179
|
-
callback,
|
180
|
-
context,
|
181
|
-
};
|
182
|
-
(0, log_1.debug)(this._moduleName, `registered callback '${name}'`);
|
183
|
-
}
|
184
|
-
else {
|
185
|
-
(0, log_1.error)(this._moduleName, `can't register callback for '${name}' - not found`);
|
186
|
-
}
|
187
|
-
}
|
188
|
-
unregisterCallback(name) {
|
189
|
-
if (name in this._callbacks) {
|
190
|
-
this._callbacks[name] = null;
|
191
|
-
delete this._callbacks[name];
|
192
|
-
(0, log_1.debug)(this._moduleName, `unregistered callback '${name}'`);
|
193
|
-
}
|
194
|
-
else {
|
195
|
-
(0, log_1.error)(this._moduleName, `can't unregister callback for '${name}' - not found`);
|
196
|
-
}
|
197
|
-
}
|
198
|
-
fireOnReport(report) {
|
199
|
-
if (this._callbacks.onreport) {
|
200
|
-
(0, helper_1.call)(this._callbacks.onreport.callback, this._callbacks.onreport.context, report);
|
201
|
-
}
|
202
|
-
}
|
203
|
-
fireOnTicket(ticket) {
|
204
|
-
if (this._callbacks.onticket) {
|
205
|
-
(0, helper_1.call)(this._callbacks.onticket.callback, this._callbacks.onticket.context, ticket);
|
206
|
-
}
|
207
|
-
}
|
208
|
-
updateConfig(config) {
|
209
|
-
this._config = config;
|
210
|
-
this._exporter.updateConfig(config);
|
211
|
-
}
|
212
|
-
get state() {
|
213
|
-
return this._state;
|
214
|
-
}
|
215
|
-
set state(newState) {
|
216
|
-
this._state = newState;
|
217
|
-
(0, log_1.debug)(this._moduleName, `state changed to ${newState}`);
|
218
|
-
}
|
219
|
-
addCustomEvent(at, category, name, description) {
|
220
|
-
this._exporter.addCustomEvent({
|
221
|
-
at: typeof at === "object" ? at.toJSON() : at,
|
222
|
-
category,
|
223
|
-
name,
|
224
|
-
description,
|
225
|
-
});
|
226
|
-
}
|
227
|
-
registerToPCEvents() {
|
228
|
-
return __awaiter(this, void 0, void 0, function* () {
|
229
|
-
const { pc } = this._config;
|
230
|
-
navigator.mediaDevices.ondevicechange = () => __awaiter(this, void 0, void 0, function* () {
|
231
|
-
try {
|
232
|
-
const devices = yield navigator.mediaDevices.enumerateDevices();
|
233
|
-
this.addCustomEvent(new Date().toJSON(), "device", `${devices.length} devices found`, "Media Devices state");
|
234
|
-
// eslint-disable-next-line no-empty
|
235
|
-
}
|
236
|
-
catch (err) {
|
237
|
-
(0, log_1.error)(this._moduleName, "can't get devices");
|
238
|
-
}
|
239
|
-
});
|
240
|
-
if (pc) {
|
241
|
-
pc.oniceconnectionstatechange = () => {
|
242
|
-
const value = pc.iceConnectionState;
|
243
|
-
if (value === models_1.ICE_CONNECTION_STATE.CONNECTED ||
|
244
|
-
value === models_1.ICE_CONNECTION_STATE.COMPLETED) {
|
245
|
-
this.addCustomEvent(new Date().toJSON(), "call", value, "ICE connection state");
|
246
|
-
}
|
247
|
-
else if (value === models_1.ICE_CONNECTION_STATE.DISCONNECTED ||
|
248
|
-
value === models_1.ICE_CONNECTION_STATE.FAILED) {
|
249
|
-
this.addCustomEvent(new Date().toJSON(), "call", value, "ICE connection state");
|
250
|
-
}
|
251
|
-
else if (value === models_1.ICE_CONNECTION_STATE.CLOSED) {
|
252
|
-
this.addCustomEvent(new Date().toJSON(), "call", "ended", "ICE connection state");
|
253
|
-
}
|
254
|
-
};
|
255
|
-
pc.onicegatheringstatechange = () => {
|
256
|
-
const value = pc.iceGatheringState;
|
257
|
-
this.addCustomEvent(new Date().toJSON(), "call", value, "ICE gathering state");
|
258
|
-
};
|
259
|
-
pc.ontrack = (e) => {
|
260
|
-
this.addCustomEvent(new Date().toJSON(), "call", `${e.track.kind}track`, "MediaStreamTrack received");
|
261
|
-
};
|
262
|
-
pc.onnegotiationneeded = () => {
|
263
|
-
this.addCustomEvent(new Date().toJSON(), "call", "negotiation", "Media changed");
|
264
|
-
};
|
265
|
-
const receivers = pc.getReceivers();
|
266
|
-
if (receivers && receivers.length > 0) {
|
267
|
-
const receiver = receivers[0];
|
268
|
-
const { transport } = receiver;
|
269
|
-
if (transport) {
|
270
|
-
const { iceTransport } = transport;
|
271
|
-
if (iceTransport) {
|
272
|
-
iceTransport.onselectedcandidatepairchange = () => {
|
273
|
-
this.addCustomEvent(new Date().toJSON(), "call", "transport", "Candidates Pair changed");
|
274
|
-
};
|
275
|
-
}
|
276
|
-
}
|
277
|
-
}
|
278
|
-
}
|
279
|
-
});
|
280
|
-
}
|
281
|
-
}
|
282
|
-
exports.default = Collector;
|
@@ -1,20 +0,0 @@
|
|
1
|
-
export default class ProbesEngine {
|
2
|
-
constructor(cfg: any);
|
3
|
-
_config: any;
|
4
|
-
_probes: any[];
|
5
|
-
_startedTime: number | null;
|
6
|
-
_callbacks: {
|
7
|
-
onresult: null;
|
8
|
-
};
|
9
|
-
get probes(): any[];
|
10
|
-
get isRunning(): boolean;
|
11
|
-
get isIdle(): boolean;
|
12
|
-
addNewProbe(peerConnection: any, options: any): Probe;
|
13
|
-
removeExistingProbe(probe: any): void;
|
14
|
-
start(): Promise<void>;
|
15
|
-
stop(forced: any): void;
|
16
|
-
registerCallback(name: any, callback: any, context: any): void;
|
17
|
-
unregisterCallback(name: any): void;
|
18
|
-
fireOnReports(report: any): void;
|
19
|
-
}
|
20
|
-
import Probe from "./probe";
|
@@ -1,164 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9
|
-
});
|
10
|
-
};
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
13
|
-
};
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
15
|
-
const log_1 = require("./utils/log");
|
16
|
-
const config_1 = require("./utils/config");
|
17
|
-
const probe_1 = __importDefault(require("./probe"));
|
18
|
-
const models_1 = require("./utils/models");
|
19
|
-
const helper_1 = require("./utils/helper");
|
20
|
-
const moduleName = "engine ";
|
21
|
-
class ProbesEngine {
|
22
|
-
constructor(cfg) {
|
23
|
-
this._config = cfg;
|
24
|
-
this._probes = [];
|
25
|
-
this._startedTime = null;
|
26
|
-
this._callbacks = {
|
27
|
-
onresult: null,
|
28
|
-
};
|
29
|
-
(0, log_1.info)(moduleName, `configured for probing every ${this._config.refreshEvery}ms`);
|
30
|
-
(0, log_1.info)(moduleName, `configured for starting after ${this._config.startAfter}ms`);
|
31
|
-
(0, log_1.info)(moduleName, `${(!this._config.stopAfter || this._config.stopAfter !== -1) ? `configured for stopped after ${this._config.stopAfter}ms` : "configured for never stopped"}`);
|
32
|
-
(0, log_1.debug)(moduleName, "engine initialized");
|
33
|
-
}
|
34
|
-
get probes() {
|
35
|
-
return this._probes;
|
36
|
-
}
|
37
|
-
get isRunning() {
|
38
|
-
return this._probes.some((probe) => (probe.isRunning));
|
39
|
-
}
|
40
|
-
get isIdle() {
|
41
|
-
return this._probes.every((probe) => (probe.isIdle));
|
42
|
-
}
|
43
|
-
addNewProbe(peerConnection, options) {
|
44
|
-
if (!peerConnection) {
|
45
|
-
throw new Error("undefined peer connection");
|
46
|
-
}
|
47
|
-
const probeConfig = (0, config_1.getConfig)(peerConnection, options, this._config);
|
48
|
-
const probe = new probe_1.default(probeConfig);
|
49
|
-
this._probes.push(probe);
|
50
|
-
(0, log_1.debug)(moduleName, `${this._probes.length} probes registered`);
|
51
|
-
return probe;
|
52
|
-
}
|
53
|
-
removeExistingProbe(probe) {
|
54
|
-
if (!probe) {
|
55
|
-
throw new Error("undefined probe");
|
56
|
-
}
|
57
|
-
if (probe.state === models_1.COLLECTOR_STATE.RUNNING) {
|
58
|
-
probe.stop();
|
59
|
-
}
|
60
|
-
this._probes = this._probes.filter((existingProbe) => (probe.id !== existingProbe.id));
|
61
|
-
}
|
62
|
-
start() {
|
63
|
-
return __awaiter(this, void 0, void 0, function* () {
|
64
|
-
const startProbes = () => {
|
65
|
-
this._probes.forEach((probe) => probe.start());
|
66
|
-
};
|
67
|
-
const takeReferenceStat = () => __awaiter(this, void 0, void 0, function* () {
|
68
|
-
return (Promise.all(this._probes.map((probe) => (probe.takeReferenceStats()))));
|
69
|
-
});
|
70
|
-
const shouldCollectStats = () => {
|
71
|
-
if (this.isIdle) {
|
72
|
-
// don't collect if there is no running probes
|
73
|
-
return false;
|
74
|
-
}
|
75
|
-
if (!this._config.stopAfter || this._config.stopAfter < 0) {
|
76
|
-
// always collect if stopAfter has not been set
|
77
|
-
return true;
|
78
|
-
}
|
79
|
-
// Else check expiration
|
80
|
-
return (Date.now() < this._startedTime + this._config.stopAfter);
|
81
|
-
};
|
82
|
-
const collectStats = () => __awaiter(this, void 0, void 0, function* () {
|
83
|
-
const globalReport = (0, models_1.getDefaultGlobalMetric)();
|
84
|
-
const runningProbes = this._probes.filter((probe) => (probe.isRunning));
|
85
|
-
for (const probe of runningProbes) {
|
86
|
-
const report = yield probe.collectStats();
|
87
|
-
if (report) {
|
88
|
-
globalReport.probes.push(report);
|
89
|
-
}
|
90
|
-
(0, log_1.debug)(moduleName, `got probe ${probe.id}`);
|
91
|
-
yield (0, helper_1.timeout)(0);
|
92
|
-
}
|
93
|
-
// Compute total measure time
|
94
|
-
globalReport.delta_time_to_measure_probes_ms = (0, helper_1.sumValuesOfReports)(globalReport.probes, "experimental", "time_to_measure_ms");
|
95
|
-
globalReport.delta_KBytes_in = (0, helper_1.sumValuesOfReports)(globalReport.probes, "data", "delta_KBytes_in");
|
96
|
-
globalReport.delta_KBytes_out = (0, helper_1.sumValuesOfReports)(globalReport.probes, "data", "delta_KBytes_out");
|
97
|
-
globalReport.delta_kbs_in = (0, helper_1.sumValuesOfReports)(globalReport.probes, "data", "delta_kbs_in");
|
98
|
-
globalReport.delta_kbs_out = (0, helper_1.sumValuesOfReports)(globalReport.probes, "data", "delta_kbs_out");
|
99
|
-
globalReport.total_time_decoded_in = (0, helper_1.sumValuesOfReports)(globalReport.probes, "video", "total_time_decoded_in");
|
100
|
-
globalReport.total_time_encoded_out = (0, helper_1.sumValuesOfReports)(globalReport.probes, "video", "total_time_encoded_out");
|
101
|
-
return globalReport;
|
102
|
-
});
|
103
|
-
(0, log_1.debug)(moduleName, "starting to collect");
|
104
|
-
startProbes();
|
105
|
-
(0, log_1.debug)(moduleName, "generating reference reports...");
|
106
|
-
yield takeReferenceStat();
|
107
|
-
(0, log_1.debug)(moduleName, "reference reports generated");
|
108
|
-
this._startedTime = Date.now();
|
109
|
-
while (shouldCollectStats()) {
|
110
|
-
(0, log_1.debug)(moduleName, `wait ${this._config.refreshEvery}ms before collecting`);
|
111
|
-
yield (0, helper_1.timeout)(this._config.refreshEvery);
|
112
|
-
if (shouldCollectStats()) {
|
113
|
-
(0, log_1.debug)(moduleName, "collecting...");
|
114
|
-
const preTime = Date.now();
|
115
|
-
const globalReport = yield collectStats();
|
116
|
-
const postTime = Date.now();
|
117
|
-
globalReport.delta_time_consumed_to_measure_ms = postTime - preTime;
|
118
|
-
this.fireOnReports(globalReport);
|
119
|
-
(0, log_1.debug)(moduleName, "collected");
|
120
|
-
}
|
121
|
-
}
|
122
|
-
(0, log_1.debug)(moduleName, "reaching end of the collecting period...");
|
123
|
-
if (this.isRunning) {
|
124
|
-
setTimeout(() => {
|
125
|
-
this.stop();
|
126
|
-
}, 0);
|
127
|
-
}
|
128
|
-
});
|
129
|
-
}
|
130
|
-
stop(forced) {
|
131
|
-
const stopProbes = (manual) => {
|
132
|
-
this._probes.forEach((probe) => {
|
133
|
-
probe.stop(manual);
|
134
|
-
});
|
135
|
-
};
|
136
|
-
(0, log_1.info)(moduleName, "stop collecting");
|
137
|
-
stopProbes(forced);
|
138
|
-
}
|
139
|
-
registerCallback(name, callback, context) {
|
140
|
-
if (name in this._callbacks) {
|
141
|
-
this._callbacks[name] = { callback, context };
|
142
|
-
(0, log_1.debug)(moduleName, `registered callback '${name}'`);
|
143
|
-
}
|
144
|
-
else {
|
145
|
-
(0, log_1.error)(moduleName, `can't register callback for '${name}' - not found`);
|
146
|
-
}
|
147
|
-
}
|
148
|
-
unregisterCallback(name) {
|
149
|
-
if (name in this._callbacks) {
|
150
|
-
this._callbacks[name] = null;
|
151
|
-
delete this._callbacks[name];
|
152
|
-
(0, log_1.debug)(this._moduleName, `unregistered callback '${name}'`);
|
153
|
-
}
|
154
|
-
else {
|
155
|
-
(0, log_1.error)(this._moduleName, `can't unregister callback for '${name}' - not found`);
|
156
|
-
}
|
157
|
-
}
|
158
|
-
fireOnReports(report) {
|
159
|
-
if (this._callbacks.onresult && report.probes.length > 0) {
|
160
|
-
(0, helper_1.call)(this._callbacks.onresult.callback, this._callbacks.onresult.context, report);
|
161
|
-
}
|
162
|
-
}
|
163
|
-
}
|
164
|
-
exports.default = ProbesEngine;
|
@@ -1,116 +0,0 @@
|
|
1
|
-
export default class Exporter {
|
2
|
-
constructor(cfg: any);
|
3
|
-
_start: string | null;
|
4
|
-
_end: string | null;
|
5
|
-
_cfg: any;
|
6
|
-
_referenceReport: any;
|
7
|
-
_reports: any[];
|
8
|
-
_events: any[];
|
9
|
-
start(): Date;
|
10
|
-
stop(): Date;
|
11
|
-
saveReferenceReport(report: any): void;
|
12
|
-
getReferenceReport(): any;
|
13
|
-
addReport(report: any): void;
|
14
|
-
addCustomEvent(event: any): void;
|
15
|
-
reset(): void;
|
16
|
-
get ticket(): {
|
17
|
-
version: string;
|
18
|
-
configuration: {
|
19
|
-
frequency: any;
|
20
|
-
};
|
21
|
-
started: string | null;
|
22
|
-
ended: string | null;
|
23
|
-
ua: {
|
24
|
-
agent: string;
|
25
|
-
pname: any;
|
26
|
-
user_id: any;
|
27
|
-
};
|
28
|
-
call: {
|
29
|
-
call_id: any;
|
30
|
-
events: any[];
|
31
|
-
};
|
32
|
-
details: {
|
33
|
-
count: number;
|
34
|
-
reports: any[];
|
35
|
-
reference: any;
|
36
|
-
};
|
37
|
-
ssrc: {};
|
38
|
-
data: {
|
39
|
-
rtt: {
|
40
|
-
avg: number | null;
|
41
|
-
min: number | null;
|
42
|
-
max: number | null;
|
43
|
-
volatility: number | null;
|
44
|
-
_unit: {
|
45
|
-
avg: string;
|
46
|
-
min: string;
|
47
|
-
max: string;
|
48
|
-
volatility: string;
|
49
|
-
};
|
50
|
-
};
|
51
|
-
packetsLost: {
|
52
|
-
audio: {
|
53
|
-
in: {
|
54
|
-
avg: number;
|
55
|
-
};
|
56
|
-
};
|
57
|
-
video: {
|
58
|
-
in: {
|
59
|
-
avg: number;
|
60
|
-
};
|
61
|
-
};
|
62
|
-
unit: {
|
63
|
-
avg: string;
|
64
|
-
};
|
65
|
-
};
|
66
|
-
bitrate: {
|
67
|
-
in: {
|
68
|
-
avg: number | null;
|
69
|
-
min: number | null;
|
70
|
-
max: number | null;
|
71
|
-
volatility: number | null;
|
72
|
-
};
|
73
|
-
out: {
|
74
|
-
avg: number | null;
|
75
|
-
min: number | null;
|
76
|
-
max: number | null;
|
77
|
-
volatility: number | null;
|
78
|
-
};
|
79
|
-
unit: {
|
80
|
-
avg: string;
|
81
|
-
min: string;
|
82
|
-
max: string;
|
83
|
-
volatility: string;
|
84
|
-
};
|
85
|
-
};
|
86
|
-
traffic: {
|
87
|
-
in: {
|
88
|
-
avg: number | null;
|
89
|
-
min: number | null;
|
90
|
-
max: number | null;
|
91
|
-
volatility: number | null;
|
92
|
-
};
|
93
|
-
out: {
|
94
|
-
avg: number | null;
|
95
|
-
min: number | null;
|
96
|
-
max: number | null;
|
97
|
-
volatility: number | null;
|
98
|
-
};
|
99
|
-
unit: {
|
100
|
-
avg: string;
|
101
|
-
min: string;
|
102
|
-
max: string;
|
103
|
-
volatility: string;
|
104
|
-
};
|
105
|
-
};
|
106
|
-
network: {
|
107
|
-
localConnection: string;
|
108
|
-
remoteConnection: string;
|
109
|
-
};
|
110
|
-
};
|
111
|
-
};
|
112
|
-
updateConfig(config: any): void;
|
113
|
-
getLastReport(): any;
|
114
|
-
getBeforeLastReport(): any;
|
115
|
-
getReportsNumber(): number;
|
116
|
-
}
|