@wireapp/avs 10.5.44 → 10.6.2
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/dist/avs_core.js +169 -25
- package/dist/avs_pc.js +34 -12
- package/dist/avs_wcall.d.ts +4 -11
- package/dist/avs_wcall.js +11 -64
- package/package.json +1 -1
- package/dist/avs_connection_test.d.ts +0 -40
- package/dist/avs_connection_test.js +0 -333
- package/dist/avs_scan.d.ts +0 -27
- package/dist/avs_scan.js +0 -263
package/dist/avs_pc.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
var avs_connection_test_1 = require("./avs_connection_test");
|
|
4
3
|
var ENV_FIREFOX = 1;
|
|
5
4
|
var TIMEOUT_GATHER = 2000;
|
|
6
5
|
var em_module;
|
|
@@ -389,6 +388,35 @@ function ccallLocalSdpHandler(pc, err, type, sdp) {
|
|
|
389
388
|
function ccallStartGatherHandler(pc) {
|
|
390
389
|
em_module.ccall("pc_start_gather_handler", null, ["number"], [pc.self]);
|
|
391
390
|
}
|
|
391
|
+
function ccallAudioJbMinMs() {
|
|
392
|
+
return em_module.ccall("pc_audio_jb_min_ms", "number", [], []);
|
|
393
|
+
}
|
|
394
|
+
/* Give the received audio the same jitter buffer minimum as the native
|
|
395
|
+
* clients (wcall_set_loss_params jb_min_ms), so the packet carrying the RED /
|
|
396
|
+
* FEC copy of a lost one arrives in time.
|
|
397
|
+
*/
|
|
398
|
+
function setAudioJitterBufferMin(pc, receiver) {
|
|
399
|
+
var ms = ccallAudioJbMinMs();
|
|
400
|
+
if (ms <= 0)
|
|
401
|
+
return;
|
|
402
|
+
var r = receiver;
|
|
403
|
+
try {
|
|
404
|
+
if ('jitterBufferTarget' in r) {
|
|
405
|
+
r.jitterBufferTarget = ms;
|
|
406
|
+
}
|
|
407
|
+
else if ('playoutDelayHint' in r) {
|
|
408
|
+
r.playoutDelayHint = ms / 1000;
|
|
409
|
+
}
|
|
410
|
+
else {
|
|
411
|
+
pc_log(LOG_LEVEL_INFO, "setAudioJitterBufferMin: self=".concat(pc.self, " not supported"));
|
|
412
|
+
return;
|
|
413
|
+
}
|
|
414
|
+
pc_log(LOG_LEVEL_INFO, "setAudioJitterBufferMin: self=".concat(pc.self, " ").concat(ms, " ms"));
|
|
415
|
+
}
|
|
416
|
+
catch (err) {
|
|
417
|
+
pc_log(LOG_LEVEL_WARN, "setAudioJitterBufferMin failed: " + err, err);
|
|
418
|
+
}
|
|
419
|
+
}
|
|
392
420
|
function ccallSignallingHandler(pc, state) {
|
|
393
421
|
em_module.ccall("pc_signalling_handler", null, ["number", "number"], [pc.self, state]);
|
|
394
422
|
}
|
|
@@ -486,7 +514,6 @@ function candidateHandler(pc, cand) {
|
|
|
486
514
|
gatheringComplete(pc);
|
|
487
515
|
return;
|
|
488
516
|
}
|
|
489
|
-
(0, avs_connection_test_1.observeTestCandidate)(pc.convid, pc.rtc, cand);
|
|
490
517
|
/* As soon as we get the first relay, we start a gathering timer
|
|
491
518
|
* this was we ensure that gathering never takes more than the
|
|
492
519
|
* timeout period.
|
|
@@ -605,7 +632,6 @@ function pc_Create(hnd, privacy, conv_type) {
|
|
|
605
632
|
pc_log(LOG_LEVEL_INFO, "pc_Create: configuring: ".concat(pc.turnServers.length, " TURN servers"));
|
|
606
633
|
var rtc = new RTCPeerConnection(config);
|
|
607
634
|
pc.rtc = rtc;
|
|
608
|
-
(0, avs_connection_test_1.observeTestPeer)(pc.convid, rtc);
|
|
609
635
|
rtc.onicegatheringstatechange = function () { return gatheringHandler(pc); };
|
|
610
636
|
rtc.onconnectionstatechange = function () { return connectionHandler(pc); };
|
|
611
637
|
rtc.onicecandidate = function (event) { return candidateHandler(pc, event.candidate); };
|
|
@@ -638,6 +664,8 @@ function pc_Create(hnd, privacy, conv_type) {
|
|
|
638
664
|
}
|
|
639
665
|
}
|
|
640
666
|
}
|
|
667
|
+
if (event.track.kind == "audio")
|
|
668
|
+
setAudioJitterBufferMin(pc, event.receiver);
|
|
641
669
|
if (event.track.kind == "audio" && audioStreamHandler) {
|
|
642
670
|
pc_log(LOG_LEVEL_INFO, "onTrack: calling ash(".concat(pc.convid.substring(0, 8), ", ").concat(label, ") with ").concat(event.streams.length, " streams"));
|
|
643
671
|
audioStreamHandler(pc.convid, hnd.toString() + label, event.streams);
|
|
@@ -804,7 +832,9 @@ function sdpCbrMap(sdp) {
|
|
|
804
832
|
sdp.split('\r\n').forEach(function (sdpLine) {
|
|
805
833
|
var outline;
|
|
806
834
|
outline = sdpLine;
|
|
807
|
-
|
|
835
|
+
// match the opus fmtp regardless of param order or appended params
|
|
836
|
+
// (e.g. maxaveragebitrate)
|
|
837
|
+
if (/^a=fmtp:\d+ .*useinbandfec=1/.test(sdpLine) && !sdpLine.includes('cbr=1')) {
|
|
808
838
|
outline = sdpLine + ";cbr=1";
|
|
809
839
|
}
|
|
810
840
|
else if (sdpLine.startsWith('a=ssrc-group:')) {
|
|
@@ -958,7 +988,6 @@ function createSdp(pc, callType, vstate, isOffer) {
|
|
|
958
988
|
if (userMediaHandler) {
|
|
959
989
|
userMediaHandler(pc.convid, true, use_video, use_ss)
|
|
960
990
|
.then(function (stream) {
|
|
961
|
-
(0, avs_connection_test_1.observeTestMicrophone)(pc.convid, rtc, stream);
|
|
962
991
|
return update_tracks(pc, stream).then(function () { return stream; });
|
|
963
992
|
}).then(function (stream) {
|
|
964
993
|
var doSdp = isOffer
|
|
@@ -977,19 +1006,14 @@ function createSdp(pc, callType, vstate, isOffer) {
|
|
|
977
1006
|
})
|
|
978
1007
|
.catch(function (err) {
|
|
979
1008
|
pc_log(LOG_LEVEL_WARN, 'createSdp: doSdp failed: ' + err, err);
|
|
980
|
-
(0, avs_connection_test_1.failTestPeer)(pc.convid, rtc, 'Could not create SDP');
|
|
981
1009
|
ccallLocalSdpHandler(pc, 1, "sdp-error", err.toString());
|
|
982
1010
|
});
|
|
983
1011
|
})
|
|
984
1012
|
.catch(function (err) {
|
|
985
1013
|
pc_log(LOG_LEVEL_WARN, 'createSdp: userMedia failed: ' + err, err);
|
|
986
|
-
(0, avs_connection_test_1.failTestPeer)(pc.convid, rtc, 'Could not open the microphone');
|
|
987
1014
|
ccallLocalSdpHandler(pc, 1, "media-error", err.toString());
|
|
988
1015
|
});
|
|
989
1016
|
}
|
|
990
|
-
else {
|
|
991
|
-
(0, avs_connection_test_1.failTestPeer)(pc.convid, rtc, 'No microphone handler configured');
|
|
992
|
-
}
|
|
993
1017
|
}
|
|
994
1018
|
function pc_CreateOffer(hnd, callType, vstate) {
|
|
995
1019
|
var pc = connectionsStore.getPeerConnection(hnd);
|
|
@@ -1130,7 +1154,6 @@ function pc_SetRemoteDescription(hnd, typePtr, sdpPtr) {
|
|
|
1130
1154
|
.then(function () { })
|
|
1131
1155
|
.catch(function (err) {
|
|
1132
1156
|
pc_log(LOG_LEVEL_WARN, "setRemoteDescription failed: " + err, err);
|
|
1133
|
-
(0, avs_connection_test_1.failTestPeer)(pc.convid, rtc, 'Could not apply remote SDP');
|
|
1134
1157
|
});
|
|
1135
1158
|
if (pc_env != ENV_FIREFOX)
|
|
1136
1159
|
extractSSRCs(pc, sdp);
|
|
@@ -1165,7 +1188,6 @@ function pc_SetLocalDescription(hnd, typePtr, sdpPtr) {
|
|
|
1165
1188
|
})
|
|
1166
1189
|
.catch(function (err) {
|
|
1167
1190
|
pc_log(LOG_LEVEL_INFO, "setLocalDescription failed: " + err, err);
|
|
1168
|
-
(0, avs_connection_test_1.failTestPeer)(pc.convid, rtc, 'Could not apply local SDP');
|
|
1169
1191
|
});
|
|
1170
1192
|
}
|
|
1171
1193
|
function pc_LocalDescription(hnd, typePtr) {
|
package/dist/avs_wcall.d.ts
CHANGED
|
@@ -1,8 +1,4 @@
|
|
|
1
1
|
import { UserMediaHandler, AudioStreamHandler, VideoStreamHandler } from "./avs_pc";
|
|
2
|
-
import { ScanReport } from "./avs_scan";
|
|
3
|
-
export type { ScanCandidate, ScanReport, ScanRun } from "./avs_scan";
|
|
4
|
-
import { ConnectionTestProgress, ConnectionTestResult } from "./avs_connection_test";
|
|
5
|
-
export type { ConnectionTestProgress, ConnectionTestResult, } from "./avs_connection_test";
|
|
6
2
|
export declare enum ERROR {
|
|
7
3
|
NO_MEMORY = 12,
|
|
8
4
|
INVALID = 22,
|
|
@@ -133,11 +129,7 @@ export type WcallActiveSpeakerHandler = (wuser: number, convid: string, json_lev
|
|
|
133
129
|
export type WcallNetprobeHandler = (err: number, rtt_avg: number, n_pkt_sent: number, n_pkt_recv: number, arg: number) => void;
|
|
134
130
|
export declare class Wcall {
|
|
135
131
|
private em_module;
|
|
136
|
-
private runScan?;
|
|
137
|
-
private runWebTest?;
|
|
138
132
|
constructor(em_module: any);
|
|
139
|
-
scanTest(wuser: number): Promise<ScanReport>;
|
|
140
|
-
runConnectionTest(wuser: number, onProgress?: (progress: ConnectionTestProgress) => void): Promise<ConnectionTestResult>;
|
|
141
133
|
init(env: number): number;
|
|
142
134
|
close(): void;
|
|
143
135
|
create(userid: string, clientid: string, readyh: WcallReadyHandler, sendh: WcallSendHandler, sfth: WcallSftReqHandler, incomingh: WcallIncomingHandler, missedh: WcallMissedHandler, answerh: WcallAnsweredHandler, estabh: WcallEstabHandler, closeh: WcallCloseHandler, metricsh: WcallMetricsHandler, cfg_reqh: WcallConfigReqHandler, acbrh: WcallAudioCbrChangeHandler, vstateh: WcallVideoStateChangeHandler, arg?: number): number;
|
|
@@ -147,8 +139,6 @@ export declare class Wcall {
|
|
|
147
139
|
setTrace(wuser: number, trace: number): void;
|
|
148
140
|
setBackground(wuser: number, background: number): number;
|
|
149
141
|
start(wuser: number, convid: string, call_type: number, conv_type: number, audio_cbr: number, meeting: number): number;
|
|
150
|
-
startTest(wuser: number, video: number): number;
|
|
151
|
-
startScan(wuser: number): number;
|
|
152
142
|
answer(wuser: number, convid: string, call_type: number, audio_cbr: number): number;
|
|
153
143
|
resp(wuser: number, status: number, reason: string, ctx: number): void;
|
|
154
144
|
configUpdate(wuser: number, err: number, json_str: string): void;
|
|
@@ -179,12 +169,15 @@ export declare class Wcall {
|
|
|
179
169
|
propsyncRequest(wuser: number, convid: string): void;
|
|
180
170
|
enablePrivacy(wuser: number, enabled: number): void;
|
|
181
171
|
setProxy(host: string, port: number): number;
|
|
172
|
+
setAudioParams(ptime: number, max_bitrate: number): void;
|
|
173
|
+
setLossParams(red: number, fec_loss_pct: number, max_bitrate: number, jb_min_ms: number): void;
|
|
182
174
|
setReqClientsHandler(wuser: number, reqch: WcallReqClientsHandler): void;
|
|
183
175
|
setClientsForConv(wuser: number, convid: string, json: string): number;
|
|
184
176
|
setActiveSpeakerHandler(wuser: number, activeh: WcallActiveSpeakerHandler): void;
|
|
185
177
|
requestVideoStreams(wuser: number, convid: string, mode: number, json: string): number;
|
|
186
178
|
processNotifications(wuser: number, processing: number): number;
|
|
187
|
-
audioRecord(wuser: number, path: string): number;
|
|
179
|
+
audioRecord(wuser: number, convid: string, path: string): number;
|
|
180
|
+
setAudioFiles(wuser: number, play_path: string, record_path: string): number;
|
|
188
181
|
poll(): void;
|
|
189
182
|
setupEx(flags: number): number;
|
|
190
183
|
eventCreate(userid: string, clientid: string, incomingh: WcallIncomingHandler, missedh: WcallMissedHandler, closeh: WcallCloseHandler, arg?: number): number;
|
package/dist/avs_wcall.js
CHANGED
|
@@ -16,42 +16,6 @@
|
|
|
16
16
|
* You should have received a copy of the GNU General Public License
|
|
17
17
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
18
18
|
*/
|
|
19
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
20
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
21
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
22
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
23
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
24
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
25
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
26
|
-
});
|
|
27
|
-
};
|
|
28
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
29
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
30
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
31
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
32
|
-
function step(op) {
|
|
33
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
34
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
35
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
36
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
37
|
-
switch (op[0]) {
|
|
38
|
-
case 0: case 1: t = op; break;
|
|
39
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
40
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
41
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
42
|
-
default:
|
|
43
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
44
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
45
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
46
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
47
|
-
if (t[2]) _.ops.pop();
|
|
48
|
-
_.trys.pop(); continue;
|
|
49
|
-
}
|
|
50
|
-
op = body.call(thisArg, _);
|
|
51
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
52
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
56
20
|
exports.getAvsInstance = exports.Wcall = exports.MODE = exports.RESOLUTION = exports.VSTREAMS = exports.STATE = exports.CONV_TYPE = exports.CALL_TYPE = exports.ENV = exports.VIDEO_STATE = exports.AUDIO_STATE = exports.LOG_LEVEL = exports.REASON = exports.QUALITY = exports.ERROR = void 0;
|
|
57
21
|
/* DO NOT edit this file by hand. It is generated by the AVS make
|
|
@@ -59,8 +23,6 @@ exports.getAvsInstance = exports.Wcall = exports.MODE = exports.RESOLUTION = exp
|
|
|
59
23
|
*/
|
|
60
24
|
var avs_core = require("./avs_core");
|
|
61
25
|
var avs_pc_1 = require("./avs_pc");
|
|
62
|
-
var avs_scan_1 = require("./avs_scan");
|
|
63
|
-
var avs_connection_test_1 = require("./avs_connection_test");
|
|
64
26
|
var ERROR;
|
|
65
27
|
(function (ERROR) {
|
|
66
28
|
ERROR[ERROR["NO_MEMORY"] = 12] = "NO_MEMORY";
|
|
@@ -179,24 +141,6 @@ var Wcall = /** @class */ (function () {
|
|
|
179
141
|
function Wcall(em_module) {
|
|
180
142
|
this.em_module = em_module;
|
|
181
143
|
}
|
|
182
|
-
Wcall.prototype.scanTest = function (wuser) {
|
|
183
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
184
|
-
return __generator(this, function (_a) {
|
|
185
|
-
if (!this.runScan)
|
|
186
|
-
this.runScan = (0, avs_scan_1.installScanDriver)(this.em_module);
|
|
187
|
-
return [2 /*return*/, this.runScan(wuser)];
|
|
188
|
-
});
|
|
189
|
-
});
|
|
190
|
-
};
|
|
191
|
-
Wcall.prototype.runConnectionTest = function (wuser, onProgress) {
|
|
192
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
193
|
-
return __generator(this, function (_a) {
|
|
194
|
-
if (!this.runWebTest)
|
|
195
|
-
this.runWebTest = (0, avs_connection_test_1.installConnectionTest)(this.em_module);
|
|
196
|
-
return [2 /*return*/, this.runWebTest(wuser, 0, onProgress)];
|
|
197
|
-
});
|
|
198
|
-
});
|
|
199
|
-
};
|
|
200
144
|
Wcall.prototype.init = function (env) {
|
|
201
145
|
avs_pc_1.default.init(this.em_module, logHandler);
|
|
202
146
|
this.em_module.ccall("wcall_setup", "number", [], []);
|
|
@@ -438,12 +382,6 @@ var Wcall = /** @class */ (function () {
|
|
|
438
382
|
Wcall.prototype.start = function (wuser, convid, call_type, conv_type, audio_cbr, meeting) {
|
|
439
383
|
return this.em_module.ccall("wcall_start", "number", ["number", "string", "number", "number", "number", "number"], [wuser, convid, call_type, conv_type, audio_cbr, meeting]);
|
|
440
384
|
};
|
|
441
|
-
Wcall.prototype.startTest = function (wuser, video) {
|
|
442
|
-
return this.em_module.ccall("wcall_start_test", "number", ["number", "number"], [wuser, video]);
|
|
443
|
-
};
|
|
444
|
-
Wcall.prototype.startScan = function (wuser) {
|
|
445
|
-
return this.em_module.ccall("wcall_start_scan", "number", ["number"], [wuser]);
|
|
446
|
-
};
|
|
447
385
|
Wcall.prototype.answer = function (wuser, convid, call_type, audio_cbr) {
|
|
448
386
|
return this.em_module.ccall("wcall_answer", "number", ["number", "string", "number", "number"], [wuser, convid, call_type, audio_cbr]);
|
|
449
387
|
};
|
|
@@ -637,6 +575,12 @@ var Wcall = /** @class */ (function () {
|
|
|
637
575
|
Wcall.prototype.setProxy = function (host, port) {
|
|
638
576
|
return this.em_module.ccall("wcall_set_proxy", "number", ["string", "number"], [host, port]);
|
|
639
577
|
};
|
|
578
|
+
Wcall.prototype.setAudioParams = function (ptime, max_bitrate) {
|
|
579
|
+
this.em_module.ccall("wcall_set_audio_params", "null", ["number", "number"], [ptime, max_bitrate]);
|
|
580
|
+
};
|
|
581
|
+
Wcall.prototype.setLossParams = function (red, fec_loss_pct, max_bitrate, jb_min_ms) {
|
|
582
|
+
this.em_module.ccall("wcall_set_loss_params", "null", ["number", "number", "number", "number"], [red, fec_loss_pct, max_bitrate, jb_min_ms]);
|
|
583
|
+
};
|
|
640
584
|
Wcall.prototype.setReqClientsHandler = function (wuser, reqch) {
|
|
641
585
|
var _this = this;
|
|
642
586
|
var fn_reqch = this.em_module.addFunction(function (wuser, convid, arg) {
|
|
@@ -664,8 +608,11 @@ var Wcall = /** @class */ (function () {
|
|
|
664
608
|
Wcall.prototype.processNotifications = function (wuser, processing) {
|
|
665
609
|
return this.em_module.ccall("wcall_process_notifications", "number", ["number", "number"], [wuser, processing]);
|
|
666
610
|
};
|
|
667
|
-
Wcall.prototype.audioRecord = function (wuser, path) {
|
|
668
|
-
return this.em_module.ccall("wcall_audio_record", "number", ["number", "string"], [wuser, path]);
|
|
611
|
+
Wcall.prototype.audioRecord = function (wuser, convid, path) {
|
|
612
|
+
return this.em_module.ccall("wcall_audio_record", "number", ["number", "string", "string"], [wuser, convid, path]);
|
|
613
|
+
};
|
|
614
|
+
Wcall.prototype.setAudioFiles = function (wuser, play_path, record_path) {
|
|
615
|
+
return this.em_module.ccall("wcall_set_audio_files", "number", ["number", "string", "string"], [wuser, play_path, record_path]);
|
|
669
616
|
};
|
|
670
617
|
Wcall.prototype.poll = function () {
|
|
671
618
|
this.em_module.ccall("wcall_poll", "null", [], []);
|
package/package.json
CHANGED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { ScanCandidate } from './avs_scan';
|
|
2
|
-
type TestStep = 'ice_gathering_finished' | 'connected' | 'media_flow' | 'measurement_finished';
|
|
3
|
-
type CandidateSummary = {
|
|
4
|
-
localCandidateFound: boolean;
|
|
5
|
-
relayCandidateFound: boolean;
|
|
6
|
-
};
|
|
7
|
-
export type ConnectionTestProgress = {
|
|
8
|
-
step: TestStep;
|
|
9
|
-
status: 'ok' | 'error';
|
|
10
|
-
candidates: CandidateSummary;
|
|
11
|
-
error?: string;
|
|
12
|
-
};
|
|
13
|
-
export interface ConnectionTestResult {
|
|
14
|
-
measurementDurationMs: number;
|
|
15
|
-
device: {
|
|
16
|
-
status: 'ok';
|
|
17
|
-
microphone: 'ready';
|
|
18
|
-
localCandidates: ScanCandidate[];
|
|
19
|
-
};
|
|
20
|
-
network: {
|
|
21
|
-
status: 'ok' | 'warning' | 'unknown';
|
|
22
|
-
selectedCandidateProtocol: 'udp' | 'tcp' | null;
|
|
23
|
-
roundTripTimeMs: number | null;
|
|
24
|
-
jitterMs: number | null;
|
|
25
|
-
packetLossPercent: number | null;
|
|
26
|
-
};
|
|
27
|
-
wireServer: {
|
|
28
|
-
status: 'ok' | 'warning' | 'unknown';
|
|
29
|
-
target: 'sft';
|
|
30
|
-
connectionStatus: 'connected';
|
|
31
|
-
route: 'direct' | 'turn' | null;
|
|
32
|
-
failureReason: null;
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
export declare function observeTestPeer(convid: string, rtc: RTCPeerConnection): void;
|
|
36
|
-
export declare function observeTestMicrophone(convid: string, rtc: RTCPeerConnection, stream: MediaStream): void;
|
|
37
|
-
export declare function observeTestCandidate(convid: string, rtc: RTCPeerConnection, candidate: RTCIceCandidate): void;
|
|
38
|
-
export declare function failTestPeer(convid: string, rtc: RTCPeerConnection, message: string): void;
|
|
39
|
-
export declare function installConnectionTest(module: any): (wuser: number, video: number, onProgress?: ((progress: ConnectionTestProgress) => void) | undefined) => Promise<ConnectionTestResult>;
|
|
40
|
-
export {};
|
|
@@ -1,333 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
-
});
|
|
21
|
-
};
|
|
22
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
24
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
-
function step(op) {
|
|
27
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
29
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
30
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
-
switch (op[0]) {
|
|
32
|
-
case 0: case 1: t = op; break;
|
|
33
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
-
default:
|
|
37
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
-
if (t[2]) _.ops.pop();
|
|
42
|
-
_.trys.pop(); continue;
|
|
43
|
-
}
|
|
44
|
-
op = body.call(thisArg, _);
|
|
45
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
50
|
-
exports.installConnectionTest = exports.failTestPeer = exports.observeTestCandidate = exports.observeTestMicrophone = exports.observeTestPeer = void 0;
|
|
51
|
-
var avs_scan_1 = require("./avs_scan");
|
|
52
|
-
var SETUP_MS = 20000;
|
|
53
|
-
var MEASUREMENT_MS = 20000;
|
|
54
|
-
var POLL_MS = 500;
|
|
55
|
-
var steps = ['ice_gathering_finished', 'connected', 'media_flow', 'measurement_finished'];
|
|
56
|
-
var peers = new Map();
|
|
57
|
-
function observeTestPeer(convid, rtc) {
|
|
58
|
-
var test = peers.get(convid);
|
|
59
|
-
if (!test)
|
|
60
|
-
return;
|
|
61
|
-
if (test.rtc && test.step > 0) {
|
|
62
|
-
test.fail('WebRTC connection was replaced');
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
test.rtc = rtc;
|
|
66
|
-
test.candidates = [];
|
|
67
|
-
test.microphoneReady = false;
|
|
68
|
-
test.mediaEstablished = false;
|
|
69
|
-
}
|
|
70
|
-
exports.observeTestPeer = observeTestPeer;
|
|
71
|
-
function observeTestMicrophone(convid, rtc, stream) {
|
|
72
|
-
var test = peers.get(convid);
|
|
73
|
-
if (!test || test.rtc !== rtc)
|
|
74
|
-
return;
|
|
75
|
-
test.microphoneReady = stream.getAudioTracks().some(function (track) { return track.readyState === 'live'; });
|
|
76
|
-
if (!test.microphoneReady)
|
|
77
|
-
test.fail('No live microphone track');
|
|
78
|
-
}
|
|
79
|
-
exports.observeTestMicrophone = observeTestMicrophone;
|
|
80
|
-
function observeTestCandidate(convid, rtc, candidate) {
|
|
81
|
-
var test = peers.get(convid);
|
|
82
|
-
if (test && test.rtc === rtc && candidate.candidate) {
|
|
83
|
-
test.candidates.push((0, avs_scan_1.normalizeIceCandidate)(candidate, String(test.candidates.length)));
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
exports.observeTestCandidate = observeTestCandidate;
|
|
87
|
-
function failTestPeer(convid, rtc, message) {
|
|
88
|
-
var test = peers.get(convid);
|
|
89
|
-
if (test && test.rtc === rtc)
|
|
90
|
-
test.fail(message);
|
|
91
|
-
}
|
|
92
|
-
exports.failTestPeer = failTestPeer;
|
|
93
|
-
function audioStats(report) {
|
|
94
|
-
var audio = {
|
|
95
|
-
sent: 0, received: 0, lost: null, jitter: null,
|
|
96
|
-
uplinkJitter: null, uplinkLossPercent: null,
|
|
97
|
-
uplinkLost: new Map(),
|
|
98
|
-
};
|
|
99
|
-
report.forEach(function (stat) {
|
|
100
|
-
var _a, _b, _c, _d;
|
|
101
|
-
if (((_a = stat.kind) !== null && _a !== void 0 ? _a : stat.mediaType) !== 'audio')
|
|
102
|
-
return;
|
|
103
|
-
if (stat.type === 'outbound-rtp') {
|
|
104
|
-
audio.sent += (_b = stat.packetsSent) !== null && _b !== void 0 ? _b : 0;
|
|
105
|
-
}
|
|
106
|
-
else if (stat.type === 'inbound-rtp') {
|
|
107
|
-
audio.received += (_c = stat.packetsReceived) !== null && _c !== void 0 ? _c : 0;
|
|
108
|
-
if (typeof stat.packetsLost === 'number')
|
|
109
|
-
audio.lost = ((_d = audio.lost) !== null && _d !== void 0 ? _d : 0) + stat.packetsLost;
|
|
110
|
-
if (typeof stat.jitter === 'number')
|
|
111
|
-
audio.jitter = stat.jitter * 1000;
|
|
112
|
-
}
|
|
113
|
-
else if (stat.type === 'remote-inbound-rtp') {
|
|
114
|
-
if (Number.isFinite(stat.jitter) && stat.jitter >= 0)
|
|
115
|
-
audio.uplinkJitter = stat.jitter * 1000;
|
|
116
|
-
if (Number.isFinite(stat.fractionLost) && stat.fractionLost >= 0 && stat.fractionLost <= 1)
|
|
117
|
-
audio.uplinkLossPercent = stat.fractionLost * 100;
|
|
118
|
-
if (Number.isFinite(stat.packetsLost))
|
|
119
|
-
audio.uplinkLost.set(stat.id, stat.packetsLost);
|
|
120
|
-
}
|
|
121
|
-
});
|
|
122
|
-
return audio;
|
|
123
|
-
}
|
|
124
|
-
function connectionStats(report) {
|
|
125
|
-
var stats = new Map();
|
|
126
|
-
var pairId;
|
|
127
|
-
report.forEach(function (stat) {
|
|
128
|
-
stats.set(stat.id, stat);
|
|
129
|
-
if (stat.type === 'transport' && stat.selectedCandidatePairId) {
|
|
130
|
-
pairId = stat.selectedCandidatePairId;
|
|
131
|
-
}
|
|
132
|
-
});
|
|
133
|
-
var pair = pairId ? stats.get(pairId) : undefined;
|
|
134
|
-
var local = pair && stats.get(pair.localCandidateId);
|
|
135
|
-
var remote = pair && stats.get(pair.remoteCandidateId);
|
|
136
|
-
var protocol = local === null || local === void 0 ? void 0 : local.protocol;
|
|
137
|
-
var route = (local === null || local === void 0 ? void 0 : local.candidateType) === 'relay' || (remote === null || remote === void 0 ? void 0 : remote.candidateType) === 'relay' ? 'turn' :
|
|
138
|
-
(local === null || local === void 0 ? void 0 : local.candidateType) && (remote === null || remote === void 0 ? void 0 : remote.candidateType) ? 'direct' : null;
|
|
139
|
-
var selectedCandidateProtocol = protocol === 'udp' || protocol === 'tcp' ? protocol : null;
|
|
140
|
-
return {
|
|
141
|
-
route: route,
|
|
142
|
-
selectedCandidateProtocol: selectedCandidateProtocol,
|
|
143
|
-
roundTripTimeMs: typeof (pair === null || pair === void 0 ? void 0 : pair.currentRoundTripTime) === 'number' ? pair.currentRoundTripTime * 1000 : null,
|
|
144
|
-
};
|
|
145
|
-
}
|
|
146
|
-
function installConnectionTest(module) {
|
|
147
|
-
var sessions = new Map();
|
|
148
|
-
module.avsWebTestEvent = function (wuser, convid, event, reason) {
|
|
149
|
-
var test = sessions.get(wuser);
|
|
150
|
-
if (!test)
|
|
151
|
-
return 0;
|
|
152
|
-
if (event === 0) {
|
|
153
|
-
if (peers.has(convid))
|
|
154
|
-
return 0;
|
|
155
|
-
test.convid = convid;
|
|
156
|
-
peers.set(convid, test);
|
|
157
|
-
return 1;
|
|
158
|
-
}
|
|
159
|
-
if (test.convid !== convid)
|
|
160
|
-
return 0;
|
|
161
|
-
if (event === 1)
|
|
162
|
-
test.mediaEstablished = true;
|
|
163
|
-
if (event === 2)
|
|
164
|
-
Promise.resolve().then(function () { return test.fail('AVS closed the test (' + reason + ')', false); });
|
|
165
|
-
return 1;
|
|
166
|
-
};
|
|
167
|
-
return function (wuser, video, onProgress) {
|
|
168
|
-
return new Promise(function (resolve, reject) {
|
|
169
|
-
if (sessions.has(wuser)) {
|
|
170
|
-
reject(new Error('Connection test already running'));
|
|
171
|
-
return;
|
|
172
|
-
}
|
|
173
|
-
var finished = false;
|
|
174
|
-
var timer;
|
|
175
|
-
var deadline;
|
|
176
|
-
var startedAt;
|
|
177
|
-
var baseline;
|
|
178
|
-
var test = { candidates: [], microphoneReady: false, mediaEstablished: false, step: 0, fail: fail };
|
|
179
|
-
sessions.set(wuser, test);
|
|
180
|
-
function emit(step, status, error) {
|
|
181
|
-
var candidates = {
|
|
182
|
-
localCandidateFound: test.candidates.length > 0,
|
|
183
|
-
relayCandidateFound: test.candidates.some(function (candidate) { return candidate.type === 'relay'; }),
|
|
184
|
-
};
|
|
185
|
-
Promise.resolve().then(function () { return onProgress === null || onProgress === void 0 ? void 0 : onProgress(__assign({ step: step, status: status, candidates: candidates }, (error ? { error: error } : {}))); })
|
|
186
|
-
.catch(function (error) { return console.warn('Connection test progress callback failed', error); });
|
|
187
|
-
}
|
|
188
|
-
function finish() {
|
|
189
|
-
finished = true;
|
|
190
|
-
clearTimeout(timer);
|
|
191
|
-
clearTimeout(deadline);
|
|
192
|
-
sessions.delete(wuser);
|
|
193
|
-
if (test.convid)
|
|
194
|
-
peers.delete(test.convid);
|
|
195
|
-
}
|
|
196
|
-
function endCall() {
|
|
197
|
-
if (test.convid)
|
|
198
|
-
module.ccall('wcall_end', null, ['number', 'string'], [wuser, test.convid]);
|
|
199
|
-
}
|
|
200
|
-
function fail(message, end) {
|
|
201
|
-
if (end === void 0) { end = true; }
|
|
202
|
-
if (finished)
|
|
203
|
-
return;
|
|
204
|
-
var step = steps[test.step];
|
|
205
|
-
finish();
|
|
206
|
-
if (end) {
|
|
207
|
-
try {
|
|
208
|
-
endCall();
|
|
209
|
-
}
|
|
210
|
-
catch (error) {
|
|
211
|
-
message += '; could not end AVS call: ' + String(error);
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
emit(step, 'error', message);
|
|
215
|
-
reject(new Error(step + ': ' + message));
|
|
216
|
-
}
|
|
217
|
-
function poll() {
|
|
218
|
-
var _a, _b;
|
|
219
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
220
|
-
var rtc, connected, report, audio, received, sent_1, lost, downlinkLoss, uplinkLoss_1, _c, route, selectedCandidateProtocol, roundTripTimeMs, status_1, result, error_1;
|
|
221
|
-
return __generator(this, function (_d) {
|
|
222
|
-
switch (_d.label) {
|
|
223
|
-
case 0:
|
|
224
|
-
if (finished)
|
|
225
|
-
return [2 /*return*/];
|
|
226
|
-
_d.label = 1;
|
|
227
|
-
case 1:
|
|
228
|
-
_d.trys.push([1, 4, , 5]);
|
|
229
|
-
rtc = test.rtc;
|
|
230
|
-
if (!rtc) return [3 /*break*/, 3];
|
|
231
|
-
if (rtc.connectionState === 'failed' || rtc.connectionState === 'closed' ||
|
|
232
|
-
(test.step === 3 && rtc.connectionState !== 'connected')) {
|
|
233
|
-
fail('WebRTC connection ' + rtc.connectionState);
|
|
234
|
-
return [2 /*return*/];
|
|
235
|
-
}
|
|
236
|
-
if (test.step === 0 && rtc.iceGatheringState === 'complete') {
|
|
237
|
-
if (!test.candidates.length) {
|
|
238
|
-
fail('ICE gathering produced no local candidates');
|
|
239
|
-
return [2 /*return*/];
|
|
240
|
-
}
|
|
241
|
-
emit(steps[test.step++], 'ok');
|
|
242
|
-
}
|
|
243
|
-
connected = rtc.connectionState === 'connected' && rtc.signalingState === 'stable' &&
|
|
244
|
-
rtc.currentLocalDescription && rtc.currentRemoteDescription;
|
|
245
|
-
if (test.step === 1 && connected)
|
|
246
|
-
emit(steps[test.step++], 'ok');
|
|
247
|
-
if (!(test.step >= 2 && connected && test.mediaEstablished && test.microphoneReady)) return [3 /*break*/, 3];
|
|
248
|
-
return [4 /*yield*/, rtc.getStats()];
|
|
249
|
-
case 2:
|
|
250
|
-
report = _d.sent();
|
|
251
|
-
if (finished)
|
|
252
|
-
return [2 /*return*/];
|
|
253
|
-
if (rtc !== test.rtc || rtc.connectionState !== 'connected') {
|
|
254
|
-
timer = setTimeout(poll, POLL_MS);
|
|
255
|
-
return [2 /*return*/];
|
|
256
|
-
}
|
|
257
|
-
audio = audioStats(report);
|
|
258
|
-
if (test.step === 2 && (audio.sent > 0 || audio.received > 0)) {
|
|
259
|
-
baseline = audio;
|
|
260
|
-
startedAt = performance.now();
|
|
261
|
-
clearTimeout(deadline);
|
|
262
|
-
deadline = setTimeout(function () { return fail('Measurement could not finish'); }, MEASUREMENT_MS + 2000);
|
|
263
|
-
emit(steps[test.step++], 'ok');
|
|
264
|
-
}
|
|
265
|
-
else if (baseline && startedAt !== undefined && performance.now() - startedAt >= MEASUREMENT_MS) {
|
|
266
|
-
received = audio.received - baseline.received;
|
|
267
|
-
sent_1 = audio.sent - baseline.sent;
|
|
268
|
-
lost = audio.lost === null ? null : Math.max(0, audio.lost - ((_a = baseline.lost) !== null && _a !== void 0 ? _a : 0));
|
|
269
|
-
downlinkLoss = lost !== null && received >= 0 && received + lost > 0
|
|
270
|
-
? 100 * lost / (received + lost)
|
|
271
|
-
: null;
|
|
272
|
-
uplinkLoss_1 = audio.uplinkLossPercent;
|
|
273
|
-
if (uplinkLoss_1 === null && sent_1 > 0 &&
|
|
274
|
-
audio.uplinkLost.size === 1 && baseline.uplinkLost.size === 1) {
|
|
275
|
-
audio.uplinkLost.forEach(function (current, id) {
|
|
276
|
-
var previous = baseline === null || baseline === void 0 ? void 0 : baseline.uplinkLost.get(id);
|
|
277
|
-
if (previous !== undefined)
|
|
278
|
-
uplinkLoss_1 = 100 * Math.min(sent_1, Math.max(0, current - previous)) / sent_1;
|
|
279
|
-
});
|
|
280
|
-
}
|
|
281
|
-
if (sent_1 <= 0 && received <= 0) {
|
|
282
|
-
fail('No audio packets during measurement');
|
|
283
|
-
return [2 /*return*/];
|
|
284
|
-
}
|
|
285
|
-
_c = connectionStats(report), route = _c.route, selectedCandidateProtocol = _c.selectedCandidateProtocol, roundTripTimeMs = _c.roundTripTimeMs;
|
|
286
|
-
status_1 = route === 'direct' ? 'ok' : route === 'turn' ? 'warning' : 'unknown';
|
|
287
|
-
result = {
|
|
288
|
-
measurementDurationMs: Math.round(performance.now() - startedAt),
|
|
289
|
-
device: { status: 'ok', microphone: 'ready', localCandidates: test.candidates },
|
|
290
|
-
network: {
|
|
291
|
-
status: status_1,
|
|
292
|
-
selectedCandidateProtocol: selectedCandidateProtocol,
|
|
293
|
-
roundTripTimeMs: roundTripTimeMs,
|
|
294
|
-
jitterMs: (_b = (received > 0 ? audio.jitter : null)) !== null && _b !== void 0 ? _b : audio.uplinkJitter,
|
|
295
|
-
packetLossPercent: downlinkLoss !== null && downlinkLoss !== void 0 ? downlinkLoss : uplinkLoss_1,
|
|
296
|
-
},
|
|
297
|
-
wireServer: { status: status_1, target: 'sft', connectionStatus: 'connected', route: route, failureReason: null },
|
|
298
|
-
};
|
|
299
|
-
endCall();
|
|
300
|
-
finish();
|
|
301
|
-
emit('measurement_finished', 'ok');
|
|
302
|
-
resolve(result);
|
|
303
|
-
return [2 /*return*/];
|
|
304
|
-
}
|
|
305
|
-
_d.label = 3;
|
|
306
|
-
case 3:
|
|
307
|
-
timer = setTimeout(poll, POLL_MS);
|
|
308
|
-
return [3 /*break*/, 5];
|
|
309
|
-
case 4:
|
|
310
|
-
error_1 = _d.sent();
|
|
311
|
-
fail(String(error_1));
|
|
312
|
-
return [3 /*break*/, 5];
|
|
313
|
-
case 5: return [2 /*return*/];
|
|
314
|
-
}
|
|
315
|
-
});
|
|
316
|
-
});
|
|
317
|
-
}
|
|
318
|
-
try {
|
|
319
|
-
var err = module.ccall('wcall_web_test_start', 'number', ['number', 'number'], [wuser, video]);
|
|
320
|
-
if (err) {
|
|
321
|
-
fail('Could not start AVS test (' + err + ')', false);
|
|
322
|
-
return;
|
|
323
|
-
}
|
|
324
|
-
deadline = setTimeout(function () { return fail('Test setup timed out'); }, SETUP_MS);
|
|
325
|
-
void poll();
|
|
326
|
-
}
|
|
327
|
-
catch (error) {
|
|
328
|
-
fail(String(error), false);
|
|
329
|
-
}
|
|
330
|
-
});
|
|
331
|
-
};
|
|
332
|
-
}
|
|
333
|
-
exports.installConnectionTest = installConnectionTest;
|