@signalapp/ringrtc 2.25.1 → 2.25.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/index.d.ts +1 -1
- package/dist/index.js +27 -27
- package/dist/ringrtc/Service.d.ts +7 -7
- package/dist/ringrtc/Service.js +75 -84
- package/dist/ringrtc/VideoSupport.d.ts +1 -1
- package/dist/ringrtc/VideoSupport.js +18 -12
- package/dist/test/CallingClass.js +29 -44
- package/dist/test/RingRTC-test.js +13 -8
- package/dist/test/Utils.d.ts +2 -2
- package/dist/test/Utils.js +3 -2
- package/package.json +3 -5
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
+
import { RingRTCType } from './ringrtc/Service';
|
|
1
2
|
export { AudioDevice, BandwidthMode, Call, CallEndedReason, CallId, CallLogLevel, CallMessageUrgency, CallSettings, CallState, CallingMessage, ConnectionState, DeviceId, GroupCall, GroupCallEndReason, GroupCallObserver, GroupMemberInfo, HangupMessage, HangupType, HttpMethod, JoinState, LocalDeviceState, OfferType, OpaqueMessage, PeekInfo, RemoteDeviceState, RingCancelReason, RingRTCType, RingUpdate, UserId, VideoCapturer, VideoRenderer, VideoRequest, } from './ringrtc/Service';
|
|
2
3
|
export { CanvasVideoRenderer, GumVideoCapturer, VideoFrameSource, MAX_VIDEO_CAPTURE_AREA, MAX_VIDEO_CAPTURE_BUFFER_SIZE, MAX_VIDEO_CAPTURE_HEIGHT, MAX_VIDEO_CAPTURE_WIDTH, } from './ringrtc/VideoSupport';
|
|
3
|
-
import { RingRTCType } from './ringrtc/Service';
|
|
4
4
|
export declare const RingRTC: RingRTCType;
|
package/dist/index.js
CHANGED
|
@@ -5,31 +5,32 @@
|
|
|
5
5
|
//
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
exports.RingRTC = exports.MAX_VIDEO_CAPTURE_WIDTH = exports.MAX_VIDEO_CAPTURE_HEIGHT = exports.MAX_VIDEO_CAPTURE_BUFFER_SIZE = exports.MAX_VIDEO_CAPTURE_AREA = exports.GumVideoCapturer = exports.CanvasVideoRenderer = exports.VideoRequest = exports.RingUpdate = exports.RingRTCType = exports.RingCancelReason = exports.RemoteDeviceState = exports.PeekInfo = exports.OpaqueMessage = exports.OfferType = exports.LocalDeviceState = exports.JoinState = exports.HttpMethod = exports.HangupType = exports.HangupMessage = exports.GroupMemberInfo = exports.GroupCallEndReason = exports.GroupCall = exports.ConnectionState = exports.CallingMessage = exports.CallState = exports.CallMessageUrgency = exports.CallLogLevel = exports.CallEndedReason = exports.Call = exports.BandwidthMode = void 0;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
Object.defineProperty(exports, "
|
|
11
|
-
Object.defineProperty(exports, "
|
|
12
|
-
Object.defineProperty(exports, "
|
|
13
|
-
Object.defineProperty(exports, "
|
|
14
|
-
Object.defineProperty(exports, "
|
|
15
|
-
Object.defineProperty(exports, "
|
|
16
|
-
Object.defineProperty(exports, "
|
|
17
|
-
Object.defineProperty(exports, "
|
|
18
|
-
Object.defineProperty(exports, "
|
|
19
|
-
Object.defineProperty(exports, "
|
|
20
|
-
Object.defineProperty(exports, "
|
|
21
|
-
Object.defineProperty(exports, "
|
|
22
|
-
Object.defineProperty(exports, "
|
|
23
|
-
Object.defineProperty(exports, "
|
|
24
|
-
Object.defineProperty(exports, "
|
|
25
|
-
Object.defineProperty(exports, "
|
|
26
|
-
Object.defineProperty(exports, "
|
|
27
|
-
Object.defineProperty(exports, "
|
|
28
|
-
Object.defineProperty(exports, "
|
|
29
|
-
Object.defineProperty(exports, "
|
|
30
|
-
Object.defineProperty(exports, "
|
|
31
|
-
Object.defineProperty(exports, "
|
|
32
|
-
Object.defineProperty(exports, "
|
|
8
|
+
const Service_1 = require("./ringrtc/Service");
|
|
9
|
+
var Service_2 = require("./ringrtc/Service");
|
|
10
|
+
Object.defineProperty(exports, "BandwidthMode", { enumerable: true, get: function () { return Service_2.BandwidthMode; } });
|
|
11
|
+
Object.defineProperty(exports, "Call", { enumerable: true, get: function () { return Service_2.Call; } });
|
|
12
|
+
Object.defineProperty(exports, "CallEndedReason", { enumerable: true, get: function () { return Service_2.CallEndedReason; } });
|
|
13
|
+
Object.defineProperty(exports, "CallLogLevel", { enumerable: true, get: function () { return Service_2.CallLogLevel; } });
|
|
14
|
+
Object.defineProperty(exports, "CallMessageUrgency", { enumerable: true, get: function () { return Service_2.CallMessageUrgency; } });
|
|
15
|
+
Object.defineProperty(exports, "CallState", { enumerable: true, get: function () { return Service_2.CallState; } });
|
|
16
|
+
Object.defineProperty(exports, "CallingMessage", { enumerable: true, get: function () { return Service_2.CallingMessage; } });
|
|
17
|
+
Object.defineProperty(exports, "ConnectionState", { enumerable: true, get: function () { return Service_2.ConnectionState; } });
|
|
18
|
+
Object.defineProperty(exports, "GroupCall", { enumerable: true, get: function () { return Service_2.GroupCall; } });
|
|
19
|
+
Object.defineProperty(exports, "GroupCallEndReason", { enumerable: true, get: function () { return Service_2.GroupCallEndReason; } });
|
|
20
|
+
Object.defineProperty(exports, "GroupMemberInfo", { enumerable: true, get: function () { return Service_2.GroupMemberInfo; } });
|
|
21
|
+
Object.defineProperty(exports, "HangupMessage", { enumerable: true, get: function () { return Service_2.HangupMessage; } });
|
|
22
|
+
Object.defineProperty(exports, "HangupType", { enumerable: true, get: function () { return Service_2.HangupType; } });
|
|
23
|
+
Object.defineProperty(exports, "HttpMethod", { enumerable: true, get: function () { return Service_2.HttpMethod; } });
|
|
24
|
+
Object.defineProperty(exports, "JoinState", { enumerable: true, get: function () { return Service_2.JoinState; } });
|
|
25
|
+
Object.defineProperty(exports, "LocalDeviceState", { enumerable: true, get: function () { return Service_2.LocalDeviceState; } });
|
|
26
|
+
Object.defineProperty(exports, "OfferType", { enumerable: true, get: function () { return Service_2.OfferType; } });
|
|
27
|
+
Object.defineProperty(exports, "OpaqueMessage", { enumerable: true, get: function () { return Service_2.OpaqueMessage; } });
|
|
28
|
+
Object.defineProperty(exports, "PeekInfo", { enumerable: true, get: function () { return Service_2.PeekInfo; } });
|
|
29
|
+
Object.defineProperty(exports, "RemoteDeviceState", { enumerable: true, get: function () { return Service_2.RemoteDeviceState; } });
|
|
30
|
+
Object.defineProperty(exports, "RingCancelReason", { enumerable: true, get: function () { return Service_2.RingCancelReason; } });
|
|
31
|
+
Object.defineProperty(exports, "RingRTCType", { enumerable: true, get: function () { return Service_2.RingRTCType; } });
|
|
32
|
+
Object.defineProperty(exports, "RingUpdate", { enumerable: true, get: function () { return Service_2.RingUpdate; } });
|
|
33
|
+
Object.defineProperty(exports, "VideoRequest", { enumerable: true, get: function () { return Service_2.VideoRequest; } });
|
|
33
34
|
var VideoSupport_1 = require("./ringrtc/VideoSupport");
|
|
34
35
|
Object.defineProperty(exports, "CanvasVideoRenderer", { enumerable: true, get: function () { return VideoSupport_1.CanvasVideoRenderer; } });
|
|
35
36
|
Object.defineProperty(exports, "GumVideoCapturer", { enumerable: true, get: function () { return VideoSupport_1.GumVideoCapturer; } });
|
|
@@ -37,5 +38,4 @@ Object.defineProperty(exports, "MAX_VIDEO_CAPTURE_AREA", { enumerable: true, get
|
|
|
37
38
|
Object.defineProperty(exports, "MAX_VIDEO_CAPTURE_BUFFER_SIZE", { enumerable: true, get: function () { return VideoSupport_1.MAX_VIDEO_CAPTURE_BUFFER_SIZE; } });
|
|
38
39
|
Object.defineProperty(exports, "MAX_VIDEO_CAPTURE_HEIGHT", { enumerable: true, get: function () { return VideoSupport_1.MAX_VIDEO_CAPTURE_HEIGHT; } });
|
|
39
40
|
Object.defineProperty(exports, "MAX_VIDEO_CAPTURE_WIDTH", { enumerable: true, get: function () { return VideoSupport_1.MAX_VIDEO_CAPTURE_WIDTH; } });
|
|
40
|
-
|
|
41
|
-
exports.RingRTC = new Service_2.RingRTCType();
|
|
41
|
+
exports.RingRTC = new Service_1.RingRTCType();
|
|
@@ -94,7 +94,7 @@ export declare class RingRTCType {
|
|
|
94
94
|
handleAudioLevels(clientId: GroupCallClientId, capturedLevel: RawAudioLevel, receivedLevels: Array<ReceivedAudioLevel>): void;
|
|
95
95
|
handleRemoteDevicesChanged(clientId: GroupCallClientId, remoteDeviceStates: Array<RemoteDeviceState>): void;
|
|
96
96
|
handlePeekChanged(clientId: GroupCallClientId, info: PeekInfo): void;
|
|
97
|
-
handlePeekResponse(
|
|
97
|
+
handlePeekResponse(requestId: number, info: PeekInfo): void;
|
|
98
98
|
handleEnded(clientId: GroupCallClientId, reason: GroupCallEndReason): void;
|
|
99
99
|
groupCallRingUpdate(groupId: GroupId, ringIdString: string, sender: GroupCallUserId, state: RingUpdate): void;
|
|
100
100
|
onLogMessage(level: number, fileName: string, line: number, message: string): void;
|
|
@@ -118,9 +118,9 @@ export declare class RingRTCType {
|
|
|
118
118
|
setOutgoingVideoIsScreenShare(callId: CallId, isScreenShare: boolean): void;
|
|
119
119
|
setVideoCapturer(callId: CallId, capturer: VideoCapturer | null): void;
|
|
120
120
|
setVideoRenderer(callId: CallId, renderer: VideoRenderer | null): void;
|
|
121
|
-
getAudioInputs(): AudioDevice
|
|
121
|
+
getAudioInputs(): Array<AudioDevice>;
|
|
122
122
|
setAudioInput(index: number): void;
|
|
123
|
-
getAudioOutputs(): AudioDevice
|
|
123
|
+
getAudioOutputs(): Array<AudioDevice>;
|
|
124
124
|
setAudioOutput(index: number): void;
|
|
125
125
|
}
|
|
126
126
|
export interface CallSettings {
|
|
@@ -449,10 +449,10 @@ export interface CallManager {
|
|
|
449
449
|
setGroupMembers(clientId: GroupCallClientId, members: Array<GroupMemberInfo>): void;
|
|
450
450
|
setMembershipProof(clientId: GroupCallClientId, proof: Buffer): void;
|
|
451
451
|
receiveGroupCallVideoFrame(clientId: GroupCallClientId, remoteDemuxId: number, buffer: Buffer, maxWidth: number, maxHeight: number): [number, number] | undefined;
|
|
452
|
-
peekGroupCall(requestId: number, sfu_url: string, membership_proof: Buffer, group_members: Array<GroupMemberInfo>):
|
|
453
|
-
getAudioInputs(): AudioDevice
|
|
452
|
+
peekGroupCall(requestId: number, sfu_url: string, membership_proof: Buffer, group_members: Array<GroupMemberInfo>): void;
|
|
453
|
+
getAudioInputs(): Array<AudioDevice>;
|
|
454
454
|
setAudioInput(index: number): void;
|
|
455
|
-
getAudioOutputs(): AudioDevice
|
|
455
|
+
getAudioOutputs(): Array<AudioDevice>;
|
|
456
456
|
setAudioOutput(index: number): void;
|
|
457
457
|
}
|
|
458
458
|
export interface CallManagerCallbacks {
|
|
@@ -478,7 +478,7 @@ export interface CallManagerCallbacks {
|
|
|
478
478
|
handleJoinStateChanged(clientId: GroupCallClientId, joinState: JoinState, demuxId: number | undefined): void;
|
|
479
479
|
handleRemoteDevicesChanged(clientId: GroupCallClientId, remoteDeviceStates: Array<RemoteDeviceState>): void;
|
|
480
480
|
handlePeekChanged(clientId: GroupCallClientId, info: PeekInfo): void;
|
|
481
|
-
handlePeekResponse(
|
|
481
|
+
handlePeekResponse(requestId: number, info: PeekInfo): void;
|
|
482
482
|
handleEnded(clientId: GroupCallClientId, reason: GroupCallEndReason): void;
|
|
483
483
|
onLogMessage(level: number, fileName: string, line: number, message: string): void;
|
|
484
484
|
}
|
package/dist/ringrtc/Service.js
CHANGED
|
@@ -37,21 +37,16 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
39
|
exports.CallLogLevel = exports.CallEndedReason = exports.CallState = exports.RingCancelReason = exports.BandwidthMode = exports.HangupType = exports.OpaqueMessage = exports.HangupMessage = exports.BusyMessage = exports.IceCandidateMessage = exports.AnswerMessage = exports.OfferType = exports.OfferMessage = exports.CallingMessage = exports.GroupCall = exports.VideoRequest = exports.GroupMemberInfo = exports.RemoteDeviceState = exports.LocalDeviceState = exports.HttpMethod = exports.RingUpdate = exports.CallMessageUrgency = exports.GroupCallEndReason = exports.JoinState = exports.ConnectionState = exports.Call = exports.RingRTCType = exports.ReceivedAudioLevel = exports.NetworkRoute = exports.PeekInfo = exports.PeekDeviceInfo = void 0;
|
|
40
|
-
/*
|
|
40
|
+
/* eslint-disable max-classes-per-file */
|
|
41
41
|
const os = __importStar(require("os"));
|
|
42
42
|
const process = __importStar(require("process"));
|
|
43
|
-
//
|
|
44
|
-
const Native = require(
|
|
45
|
-
os.platform() +
|
|
46
|
-
'/libringrtc-' +
|
|
47
|
-
process.arch +
|
|
48
|
-
'.node');
|
|
43
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires, import/no-dynamic-require
|
|
44
|
+
const Native = require(`../../build/${os.platform()}/libringrtc-${process.arch}.node`);
|
|
49
45
|
class Config {
|
|
50
46
|
constructor() {
|
|
51
47
|
this.use_new_audio_device_module = false;
|
|
52
48
|
}
|
|
53
49
|
}
|
|
54
|
-
// tslint:disable-next-line no-unnecessary-class
|
|
55
50
|
class NativeCallManager {
|
|
56
51
|
constructor(observer) {
|
|
57
52
|
this.observer = observer;
|
|
@@ -61,9 +56,11 @@ class NativeCallManager {
|
|
|
61
56
|
this.createCallEndpoint(config);
|
|
62
57
|
}
|
|
63
58
|
createCallEndpoint(config) {
|
|
59
|
+
/* eslint-disable prefer-template */
|
|
64
60
|
const fieldTrialsString = Object.entries(config.field_trials || {})
|
|
65
61
|
.map(([k, v]) => `${k}/${v}`)
|
|
66
62
|
.join('/') + '/';
|
|
63
|
+
/* eslint-enable prefer-template */
|
|
67
64
|
Object.defineProperty(this, Native.callEndpointPropertyKey, {
|
|
68
65
|
configurable: true,
|
|
69
66
|
get() {
|
|
@@ -71,12 +68,13 @@ class NativeCallManager {
|
|
|
71
68
|
if (process.platform === 'darwin') {
|
|
72
69
|
// Preload devices to work around
|
|
73
70
|
// https://bugs.chromium.org/p/chromium/issues/detail?id=1287628
|
|
74
|
-
window.navigator.mediaDevices.enumerateDevices();
|
|
71
|
+
void window.navigator.mediaDevices.enumerateDevices();
|
|
75
72
|
}
|
|
76
73
|
Object.defineProperty(this, Native.callEndpointPropertyKey, {
|
|
77
74
|
configurable: true,
|
|
78
75
|
value: callEndpoint,
|
|
79
76
|
});
|
|
77
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
80
78
|
return callEndpoint;
|
|
81
79
|
},
|
|
82
80
|
});
|
|
@@ -242,7 +240,7 @@ class CallInfo {
|
|
|
242
240
|
class RingRTCType {
|
|
243
241
|
getCallInfoKey(callId) {
|
|
244
242
|
// CallId is u64 so use a string key instead.
|
|
245
|
-
return callId.high
|
|
243
|
+
return `${callId.high}${callId.low}`;
|
|
246
244
|
}
|
|
247
245
|
constructor() {
|
|
248
246
|
// Set by UX
|
|
@@ -281,7 +279,7 @@ class RingRTCType {
|
|
|
281
279
|
}
|
|
282
280
|
// Called by UX
|
|
283
281
|
cancelGroupRing(groupId, ringId, reason) {
|
|
284
|
-
|
|
282
|
+
sillyDeadlockProtection(() => {
|
|
285
283
|
this.callManager.cancelGroupRing(groupId, ringId.toString(), reason);
|
|
286
284
|
});
|
|
287
285
|
}
|
|
@@ -305,7 +303,7 @@ class RingRTCType {
|
|
|
305
303
|
}
|
|
306
304
|
})
|
|
307
305
|
.catch(e => {
|
|
308
|
-
this.logError(
|
|
306
|
+
this.logError(`RingRTC.handleStartCall exception: ${e}`);
|
|
309
307
|
call.ignore();
|
|
310
308
|
});
|
|
311
309
|
}
|
|
@@ -331,8 +329,7 @@ class RingRTCType {
|
|
|
331
329
|
}
|
|
332
330
|
const isIncoming = true;
|
|
333
331
|
const call = new Call(this.callManager, remoteUserId, callId, isIncoming, isVideoCall, CallState.Prering);
|
|
334
|
-
const handleIncomingCall = this
|
|
335
|
-
const handleStartCall = this.handleStartCall;
|
|
332
|
+
const { handleIncomingCall, handleStartCall } = this;
|
|
336
333
|
if (!handleIncomingCall || !handleStartCall) {
|
|
337
334
|
call.ignore();
|
|
338
335
|
return;
|
|
@@ -346,25 +343,25 @@ class RingRTCType {
|
|
|
346
343
|
}
|
|
347
344
|
else {
|
|
348
345
|
handleStartCall(call)
|
|
349
|
-
.then(
|
|
350
|
-
if (!
|
|
346
|
+
.then(innerSuccess => {
|
|
347
|
+
if (!innerSuccess) {
|
|
351
348
|
this.logWarn('RingRTC.handleStartCall failed for incoming call. Call ignored.');
|
|
352
349
|
call.ignore();
|
|
353
350
|
}
|
|
354
351
|
})
|
|
355
352
|
.catch(e => {
|
|
356
|
-
this.logError(
|
|
353
|
+
this.logError(`RingRTC.handleStartCall exception: ${e}`);
|
|
357
354
|
call.ignore();
|
|
358
355
|
});
|
|
359
356
|
}
|
|
360
357
|
})
|
|
361
358
|
.catch(e => {
|
|
362
|
-
this.logError(
|
|
359
|
+
this.logError(`RingRTC.handleIncomingCall exception: ${e}`);
|
|
363
360
|
call.ignore();
|
|
364
361
|
});
|
|
365
362
|
}
|
|
366
363
|
proceed(callId, settings) {
|
|
367
|
-
|
|
364
|
+
sillyDeadlockProtection(() => {
|
|
368
365
|
this.callManager.proceed(callId, settings.iceServer.username || '', settings.iceServer.password || '', settings.iceServer.urls, settings.hideIp, settings.bandwidthMode, settings.audioLevelsIntervalMillis || 0);
|
|
369
366
|
});
|
|
370
367
|
}
|
|
@@ -378,7 +375,7 @@ class RingRTCType {
|
|
|
378
375
|
}
|
|
379
376
|
// Called by Rust
|
|
380
377
|
onCallEnded(remoteUserId, callId, reason, ageSec) {
|
|
381
|
-
|
|
378
|
+
const callInfo = this._callInfoByCallId.get(this.getCallInfoKey(callId));
|
|
382
379
|
const { isVideoCall, receivedAtCounter } = callInfo || {
|
|
383
380
|
isVideoCall: false,
|
|
384
381
|
receivedAtCounter: undefined,
|
|
@@ -472,7 +469,7 @@ class RingRTCType {
|
|
|
472
469
|
if (!call) {
|
|
473
470
|
return;
|
|
474
471
|
}
|
|
475
|
-
if (
|
|
472
|
+
if ((_a = this._call) === null || _a === void 0 ? void 0 : _a.renderVideoFrame) {
|
|
476
473
|
(_b = this._call) === null || _b === void 0 ? void 0 : _b.renderVideoFrame(width, height, buffer);
|
|
477
474
|
}
|
|
478
475
|
}
|
|
@@ -522,10 +519,12 @@ class RingRTCType {
|
|
|
522
519
|
this.sendSignaling(remoteUserId, remoteDeviceId, callId, broadcast, message);
|
|
523
520
|
}
|
|
524
521
|
sendSignaling(remoteUserId, remoteDeviceId, callId, broadcast, message) {
|
|
522
|
+
/* eslint-disable no-param-reassign */
|
|
525
523
|
message.supportsMultiRing = true;
|
|
526
524
|
if (!broadcast) {
|
|
527
525
|
message.destinationDeviceId = remoteDeviceId;
|
|
528
526
|
}
|
|
527
|
+
/* eslint-enable no-param-reassign */
|
|
529
528
|
(() => __awaiter(this, void 0, void 0, function* () {
|
|
530
529
|
if (this.handleOutgoingSignaling) {
|
|
531
530
|
const signalingResult = yield this.handleOutgoingSignaling(remoteUserId, message);
|
|
@@ -539,10 +538,10 @@ class RingRTCType {
|
|
|
539
538
|
else {
|
|
540
539
|
this.callManager.signalingMessageSendFailed(callId);
|
|
541
540
|
}
|
|
542
|
-
}))();
|
|
541
|
+
}))().catch(e => this.logError(e.toString()));
|
|
543
542
|
}
|
|
544
543
|
receivedHttpResponse(requestId, status, body) {
|
|
545
|
-
|
|
544
|
+
sillyDeadlockProtection(() => {
|
|
546
545
|
try {
|
|
547
546
|
this.callManager.receivedHttpResponse(requestId, status, body);
|
|
548
547
|
}
|
|
@@ -553,7 +552,7 @@ class RingRTCType {
|
|
|
553
552
|
});
|
|
554
553
|
}
|
|
555
554
|
httpRequestFailed(requestId, debugInfo) {
|
|
556
|
-
|
|
555
|
+
sillyDeadlockProtection(() => {
|
|
557
556
|
try {
|
|
558
557
|
this.callManager.httpRequestFailed(requestId, debugInfo);
|
|
559
558
|
}
|
|
@@ -573,19 +572,18 @@ class RingRTCType {
|
|
|
573
572
|
// Called by UX
|
|
574
573
|
// Returns a list of user IDs
|
|
575
574
|
peekGroupCall(sfuUrl, membershipProof, groupMembers) {
|
|
576
|
-
|
|
575
|
+
const [requestId, promise] = this._peekRequests.add();
|
|
577
576
|
// Response comes back via handlePeekResponse
|
|
578
|
-
|
|
577
|
+
sillyDeadlockProtection(() => {
|
|
579
578
|
this.callManager.peekGroupCall(requestId, sfuUrl, membershipProof, groupMembers);
|
|
580
579
|
});
|
|
581
580
|
return promise;
|
|
582
581
|
}
|
|
583
582
|
// Called by Rust
|
|
584
583
|
requestMembershipProof(clientId) {
|
|
585
|
-
|
|
586
|
-
|
|
584
|
+
sillyDeadlockProtection(() => {
|
|
585
|
+
const groupCall = this._groupCallByClientId.get(clientId);
|
|
587
586
|
if (!groupCall) {
|
|
588
|
-
let error = new Error();
|
|
589
587
|
this.logError('requestMembershipProof(): GroupCall not found in map!');
|
|
590
588
|
return;
|
|
591
589
|
}
|
|
@@ -594,10 +592,9 @@ class RingRTCType {
|
|
|
594
592
|
}
|
|
595
593
|
// Called by Rust
|
|
596
594
|
requestGroupMembers(clientId) {
|
|
597
|
-
|
|
598
|
-
|
|
595
|
+
sillyDeadlockProtection(() => {
|
|
596
|
+
const groupCall = this._groupCallByClientId.get(clientId);
|
|
599
597
|
if (!groupCall) {
|
|
600
|
-
let error = new Error();
|
|
601
598
|
this.logError('requestGroupMembers(): GroupCall not found in map!');
|
|
602
599
|
return;
|
|
603
600
|
}
|
|
@@ -606,10 +603,9 @@ class RingRTCType {
|
|
|
606
603
|
}
|
|
607
604
|
// Called by Rust
|
|
608
605
|
handleConnectionStateChanged(clientId, connectionState) {
|
|
609
|
-
|
|
610
|
-
|
|
606
|
+
sillyDeadlockProtection(() => {
|
|
607
|
+
const groupCall = this._groupCallByClientId.get(clientId);
|
|
611
608
|
if (!groupCall) {
|
|
612
|
-
let error = new Error();
|
|
613
609
|
this.logError('handleConnectionStateChanged(): GroupCall not found in map!');
|
|
614
610
|
return;
|
|
615
611
|
}
|
|
@@ -618,10 +614,9 @@ class RingRTCType {
|
|
|
618
614
|
}
|
|
619
615
|
// Called by Rust
|
|
620
616
|
handleJoinStateChanged(clientId, joinState, demuxId) {
|
|
621
|
-
|
|
622
|
-
|
|
617
|
+
sillyDeadlockProtection(() => {
|
|
618
|
+
const groupCall = this._groupCallByClientId.get(clientId);
|
|
623
619
|
if (!groupCall) {
|
|
624
|
-
let error = new Error();
|
|
625
620
|
this.logError('handleJoinStateChanged(): GroupCall not found in map!');
|
|
626
621
|
return;
|
|
627
622
|
}
|
|
@@ -630,8 +625,8 @@ class RingRTCType {
|
|
|
630
625
|
}
|
|
631
626
|
// Called by Rust
|
|
632
627
|
handleNetworkRouteChanged(clientId, localNetworkAdapterType) {
|
|
633
|
-
|
|
634
|
-
|
|
628
|
+
sillyDeadlockProtection(() => {
|
|
629
|
+
const groupCall = this._groupCallByClientId.get(clientId);
|
|
635
630
|
if (!groupCall) {
|
|
636
631
|
this.logError('handleNetworkRouteChanged(): GroupCall not found in map!');
|
|
637
632
|
return;
|
|
@@ -641,19 +636,18 @@ class RingRTCType {
|
|
|
641
636
|
}
|
|
642
637
|
// Called by Rust
|
|
643
638
|
handleAudioLevels(clientId, capturedLevel, receivedLevels) {
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
if (
|
|
639
|
+
sillyDeadlockProtection(() => {
|
|
640
|
+
const groupCall = this._groupCallByClientId.get(clientId);
|
|
641
|
+
if (groupCall) {
|
|
647
642
|
groupCall.handleAudioLevels(capturedLevel, receivedLevels);
|
|
648
643
|
}
|
|
649
644
|
});
|
|
650
645
|
}
|
|
651
646
|
// Called by Rust
|
|
652
647
|
handleRemoteDevicesChanged(clientId, remoteDeviceStates) {
|
|
653
|
-
|
|
654
|
-
|
|
648
|
+
sillyDeadlockProtection(() => {
|
|
649
|
+
const groupCall = this._groupCallByClientId.get(clientId);
|
|
655
650
|
if (!groupCall) {
|
|
656
|
-
let error = new Error();
|
|
657
651
|
this.logError('handleRemoteDevicesChanged(): GroupCall not found in map!');
|
|
658
652
|
return;
|
|
659
653
|
}
|
|
@@ -662,10 +656,9 @@ class RingRTCType {
|
|
|
662
656
|
}
|
|
663
657
|
// Called by Rust
|
|
664
658
|
handlePeekChanged(clientId, info) {
|
|
665
|
-
|
|
666
|
-
|
|
659
|
+
sillyDeadlockProtection(() => {
|
|
660
|
+
const groupCall = this._groupCallByClientId.get(clientId);
|
|
667
661
|
if (!groupCall) {
|
|
668
|
-
let error = new Error();
|
|
669
662
|
this.logError('handlePeekChanged(): GroupCall not found in map!');
|
|
670
663
|
return;
|
|
671
664
|
}
|
|
@@ -673,19 +666,18 @@ class RingRTCType {
|
|
|
673
666
|
});
|
|
674
667
|
}
|
|
675
668
|
// Called by Rust
|
|
676
|
-
handlePeekResponse(
|
|
677
|
-
|
|
678
|
-
if (!this._peekRequests.resolve(
|
|
679
|
-
this.logWarn(`Invalid request ID for handlePeekResponse: ${
|
|
669
|
+
handlePeekResponse(requestId, info) {
|
|
670
|
+
sillyDeadlockProtection(() => {
|
|
671
|
+
if (!this._peekRequests.resolve(requestId, info)) {
|
|
672
|
+
this.logWarn(`Invalid request ID for handlePeekResponse: ${requestId}`);
|
|
680
673
|
}
|
|
681
674
|
});
|
|
682
675
|
}
|
|
683
676
|
// Called by Rust
|
|
684
677
|
handleEnded(clientId, reason) {
|
|
685
|
-
|
|
686
|
-
|
|
678
|
+
sillyDeadlockProtection(() => {
|
|
679
|
+
const groupCall = this._groupCallByClientId.get(clientId);
|
|
687
680
|
if (!groupCall) {
|
|
688
|
-
let error = new Error();
|
|
689
681
|
this.logError('handleEnded(): GroupCall not found in map!');
|
|
690
682
|
return;
|
|
691
683
|
}
|
|
@@ -695,7 +687,7 @@ class RingRTCType {
|
|
|
695
687
|
}
|
|
696
688
|
// Called by Rust
|
|
697
689
|
groupCallRingUpdate(groupId, ringIdString, sender, state) {
|
|
698
|
-
|
|
690
|
+
sillyDeadlockProtection(() => {
|
|
699
691
|
if (this.handleGroupCallRingUpdate) {
|
|
700
692
|
const ringId = BigInt(ringIdString);
|
|
701
693
|
this.handleGroupCallRingUpdate(groupId, ringId, sender, state);
|
|
@@ -724,16 +716,16 @@ class RingRTCType {
|
|
|
724
716
|
this.onLogMessage(CallLogLevel.Info, 'Service.ts', 0, message);
|
|
725
717
|
}
|
|
726
718
|
// Called by MessageReceiver
|
|
727
|
-
// tslint:disable-next-line cyclomatic-complexity
|
|
728
719
|
handleCallingMessage(remoteUserId, remoteUuid, remoteDeviceId, localDeviceId, messageAgeSec, messageReceivedAtCounter, message, senderIdentityKey, receiverIdentityKey) {
|
|
720
|
+
var _a, _b, _c, _d, _e;
|
|
729
721
|
if (message.destinationDeviceId &&
|
|
730
722
|
message.destinationDeviceId !== localDeviceId) {
|
|
731
723
|
// Drop the message as it isn't for this device, handleIgnoredCall() is not needed.
|
|
732
724
|
return;
|
|
733
725
|
}
|
|
734
|
-
if (message.offer
|
|
726
|
+
if ((_a = message.offer) === null || _a === void 0 ? void 0 : _a.callId) {
|
|
735
727
|
const callId = message.offer.callId;
|
|
736
|
-
const opaque =
|
|
728
|
+
const opaque = toBuffer(message.offer.opaque);
|
|
737
729
|
// opaque is required. sdp is obsolete, but it might still come with opaque.
|
|
738
730
|
if (!opaque) {
|
|
739
731
|
// TODO: Remove once the proto is updated to only support opaque and require it.
|
|
@@ -742,13 +734,13 @@ class RingRTCType {
|
|
|
742
734
|
}
|
|
743
735
|
const offerType = message.offer.type || OfferType.AudioCall;
|
|
744
736
|
// Save the call details for later when the call is ended.
|
|
745
|
-
|
|
737
|
+
const callInfo = new CallInfo(offerType === OfferType.VideoCall, messageReceivedAtCounter);
|
|
746
738
|
this._callInfoByCallId.set(this.getCallInfoKey(callId), callInfo);
|
|
747
739
|
this.callManager.receivedOffer(remoteUserId, remoteDeviceId, localDeviceId, messageAgeSec, callId, offerType, opaque, senderIdentityKey, receiverIdentityKey);
|
|
748
740
|
}
|
|
749
|
-
if (message.answer
|
|
741
|
+
if ((_b = message.answer) === null || _b === void 0 ? void 0 : _b.callId) {
|
|
750
742
|
const callId = message.answer.callId;
|
|
751
|
-
const opaque =
|
|
743
|
+
const opaque = toBuffer(message.answer.opaque);
|
|
752
744
|
// opaque is required. sdp is obsolete, but it might still come with opaque.
|
|
753
745
|
if (!opaque) {
|
|
754
746
|
// TODO: Remove once the proto is updated to only support opaque and require it.
|
|
@@ -759,11 +751,11 @@ class RingRTCType {
|
|
|
759
751
|
}
|
|
760
752
|
if (message.iceCandidates && message.iceCandidates.length > 0) {
|
|
761
753
|
// We assume they all have the same .callId
|
|
762
|
-
|
|
754
|
+
const callId = message.iceCandidates[0].callId;
|
|
763
755
|
// We have to copy them to do the .toArrayBuffer() thing.
|
|
764
756
|
const candidates = [];
|
|
765
757
|
for (const candidate of message.iceCandidates) {
|
|
766
|
-
const copy =
|
|
758
|
+
const copy = toBuffer(candidate.opaque);
|
|
767
759
|
if (copy) {
|
|
768
760
|
candidates.push(copy);
|
|
769
761
|
}
|
|
@@ -779,19 +771,19 @@ class RingRTCType {
|
|
|
779
771
|
}
|
|
780
772
|
this.callManager.receivedIceCandidates(remoteUserId, remoteDeviceId, callId, candidates);
|
|
781
773
|
}
|
|
782
|
-
if (message.hangup
|
|
774
|
+
if ((_c = message.hangup) === null || _c === void 0 ? void 0 : _c.callId) {
|
|
783
775
|
const callId = message.hangup.callId;
|
|
784
776
|
const hangupType = message.hangup.type || HangupType.Normal;
|
|
785
777
|
const hangupDeviceId = message.hangup.deviceId || null;
|
|
786
778
|
this.callManager.receivedHangup(remoteUserId, remoteDeviceId, callId, hangupType, hangupDeviceId);
|
|
787
779
|
}
|
|
788
|
-
if (message.legacyHangup
|
|
780
|
+
if ((_d = message.legacyHangup) === null || _d === void 0 ? void 0 : _d.callId) {
|
|
789
781
|
const callId = message.legacyHangup.callId;
|
|
790
782
|
const hangupType = message.legacyHangup.type || HangupType.Normal;
|
|
791
783
|
const hangupDeviceId = message.legacyHangup.deviceId || null;
|
|
792
784
|
this.callManager.receivedHangup(remoteUserId, remoteDeviceId, callId, hangupType, hangupDeviceId);
|
|
793
785
|
}
|
|
794
|
-
if (message.busy
|
|
786
|
+
if ((_e = message.busy) === null || _e === void 0 ? void 0 : _e.callId) {
|
|
795
787
|
const callId = message.busy.callId;
|
|
796
788
|
this.callManager.receivedBusy(remoteUserId, remoteDeviceId, callId);
|
|
797
789
|
}
|
|
@@ -800,7 +792,7 @@ class RingRTCType {
|
|
|
800
792
|
this.logError('handleCallingMessage(): opaque message received without UUID!');
|
|
801
793
|
return;
|
|
802
794
|
}
|
|
803
|
-
const data =
|
|
795
|
+
const data = toBuffer(message.opaque.data);
|
|
804
796
|
if (data == undefined) {
|
|
805
797
|
this.logError('handleCallingMessage(): opaque message received without data!');
|
|
806
798
|
return;
|
|
@@ -840,10 +832,10 @@ class RingRTCType {
|
|
|
840
832
|
return this._call;
|
|
841
833
|
}
|
|
842
834
|
getCall(callId) {
|
|
843
|
-
const
|
|
835
|
+
const call = this.call;
|
|
844
836
|
if (call &&
|
|
845
837
|
call.callId.high === callId.high &&
|
|
846
|
-
call.callId.low ===
|
|
838
|
+
call.callId.low === callId.low) {
|
|
847
839
|
return call;
|
|
848
840
|
}
|
|
849
841
|
return null;
|
|
@@ -965,7 +957,7 @@ class Call {
|
|
|
965
957
|
this._state = state;
|
|
966
958
|
this.enableOrDisableCapturer();
|
|
967
959
|
this.enableOrDisableRenderer();
|
|
968
|
-
if (
|
|
960
|
+
if (this.handleStateChanged) {
|
|
969
961
|
this.handleStateChanged();
|
|
970
962
|
}
|
|
971
963
|
}
|
|
@@ -999,7 +991,7 @@ class Call {
|
|
|
999
991
|
this._videoRenderer.disable();
|
|
1000
992
|
}
|
|
1001
993
|
// This assumes we only have one active call.
|
|
1002
|
-
|
|
994
|
+
sillyDeadlockProtection(() => {
|
|
1003
995
|
this._callManager.hangup();
|
|
1004
996
|
});
|
|
1005
997
|
}
|
|
@@ -1009,7 +1001,7 @@ class Call {
|
|
|
1009
1001
|
set outgoingAudioEnabled(enabled) {
|
|
1010
1002
|
this._outgoingAudioEnabled = enabled;
|
|
1011
1003
|
// This assumes we only have one active call.
|
|
1012
|
-
|
|
1004
|
+
sillyDeadlockProtection(() => {
|
|
1013
1005
|
this._callManager.setOutgoingAudioEnabled(enabled);
|
|
1014
1006
|
});
|
|
1015
1007
|
}
|
|
@@ -1023,7 +1015,7 @@ class Call {
|
|
|
1023
1015
|
set outgoingVideoIsScreenShare(isScreenShare) {
|
|
1024
1016
|
// This assumes we only have one active call.
|
|
1025
1017
|
this._outgoingVideoIsScreenShare = isScreenShare;
|
|
1026
|
-
|
|
1018
|
+
sillyDeadlockProtection(() => {
|
|
1027
1019
|
this._callManager.setOutgoingVideoIsScreenShare(isScreenShare);
|
|
1028
1020
|
});
|
|
1029
1021
|
}
|
|
@@ -1079,7 +1071,7 @@ class Call {
|
|
|
1079
1071
|
}
|
|
1080
1072
|
}
|
|
1081
1073
|
setOutgoingVideoEnabled(enabled) {
|
|
1082
|
-
|
|
1074
|
+
sillyDeadlockProtection(() => {
|
|
1083
1075
|
try {
|
|
1084
1076
|
this._callManager.setOutgoingVideoEnabled(enabled);
|
|
1085
1077
|
}
|
|
@@ -1090,7 +1082,7 @@ class Call {
|
|
|
1090
1082
|
});
|
|
1091
1083
|
}
|
|
1092
1084
|
updateBandwidthMode(bandwidthMode) {
|
|
1093
|
-
|
|
1085
|
+
sillyDeadlockProtection(() => {
|
|
1094
1086
|
try {
|
|
1095
1087
|
this._callManager.updateBandwidthMode(bandwidthMode);
|
|
1096
1088
|
}
|
|
@@ -1354,7 +1346,7 @@ class GroupCall {
|
|
|
1354
1346
|
this._localDeviceState.audioLevel = normalizeAudioLevel(capturedLevel);
|
|
1355
1347
|
if (this._remoteDeviceStates != undefined) {
|
|
1356
1348
|
for (const received of receivedLevels) {
|
|
1357
|
-
for (
|
|
1349
|
+
for (const remoteDeviceState of this._remoteDeviceStates) {
|
|
1358
1350
|
if (remoteDeviceState.demuxId == received.demuxId) {
|
|
1359
1351
|
remoteDeviceState.audioLevel = normalizeAudioLevel(received.level);
|
|
1360
1352
|
}
|
|
@@ -1415,14 +1407,14 @@ class GroupCallVideoFrameSource {
|
|
|
1415
1407
|
receiveVideoFrame(buffer, maxWidth, maxHeight) {
|
|
1416
1408
|
// This assumes we only have one active call.
|
|
1417
1409
|
const frame = this._callManager.receiveGroupCallVideoFrame(this._groupCall.clientId, this._remoteDemuxId, buffer, maxWidth, maxHeight);
|
|
1418
|
-
if (
|
|
1410
|
+
if (frame) {
|
|
1419
1411
|
const [width, height] = frame;
|
|
1420
1412
|
this._groupCall.setRemoteAspectRatio(this._remoteDemuxId, width / height);
|
|
1421
1413
|
}
|
|
1422
1414
|
return frame;
|
|
1423
1415
|
}
|
|
1424
1416
|
}
|
|
1425
|
-
function
|
|
1417
|
+
function toBuffer(pbab) {
|
|
1426
1418
|
if (!pbab) {
|
|
1427
1419
|
return pbab;
|
|
1428
1420
|
}
|
|
@@ -1516,11 +1508,10 @@ var CallLogLevel;
|
|
|
1516
1508
|
CallLogLevel[CallLogLevel["Debug"] = 4] = "Debug";
|
|
1517
1509
|
CallLogLevel[CallLogLevel["Trace"] = 5] = "Trace";
|
|
1518
1510
|
})(CallLogLevel = exports.CallLogLevel || (exports.CallLogLevel = {}));
|
|
1519
|
-
function
|
|
1520
|
-
|
|
1521
|
-
(() => __awaiter(this, void 0, void 0, function* () {
|
|
1511
|
+
function sillyDeadlockProtection(f) {
|
|
1512
|
+
void (() => __awaiter(this, void 0, void 0, function* () {
|
|
1522
1513
|
// This is a silly way of preventing a deadlock.
|
|
1523
|
-
//
|
|
1514
|
+
// eslint-disable-next-line @typescript-eslint/await-thenable
|
|
1524
1515
|
yield 0;
|
|
1525
1516
|
f();
|
|
1526
1517
|
}))();
|
|
@@ -46,7 +46,7 @@ export declare class GumVideoCapturer {
|
|
|
46
46
|
enableCaptureAndSend(sender: VideoFrameSender, options?: GumVideoCaptureOptions): void;
|
|
47
47
|
disable(): void;
|
|
48
48
|
setPreferredDevice(deviceId: string): Promise<void>;
|
|
49
|
-
enumerateDevices(): Promise<MediaDeviceInfo
|
|
49
|
+
enumerateDevices(): Promise<Array<MediaDeviceInfo>>;
|
|
50
50
|
private getUserMedia;
|
|
51
51
|
private startCapturing;
|
|
52
52
|
private stopCapturing;
|
|
@@ -22,6 +22,7 @@ var VideoPixelFormatEnum;
|
|
|
22
22
|
VideoPixelFormatEnum[VideoPixelFormatEnum["Nv12"] = 1] = "Nv12";
|
|
23
23
|
VideoPixelFormatEnum[VideoPixelFormatEnum["Rgba"] = 2] = "Rgba";
|
|
24
24
|
})(VideoPixelFormatEnum = exports.VideoPixelFormatEnum || (exports.VideoPixelFormatEnum = {}));
|
|
25
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
25
26
|
function videoPixelFormatFromEnum(format) {
|
|
26
27
|
switch (format) {
|
|
27
28
|
case VideoPixelFormatEnum.I420: {
|
|
@@ -82,11 +83,11 @@ class GumVideoCapturer {
|
|
|
82
83
|
this.updateLocalPreviewIntervalId = setInterval(this.updateLocalPreviewSourceObject.bind(this), 1000);
|
|
83
84
|
}
|
|
84
85
|
enableCapture() {
|
|
85
|
-
//
|
|
86
|
+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
86
87
|
this.startCapturing(this.defaultCaptureOptions);
|
|
87
88
|
}
|
|
88
89
|
enableCaptureAndSend(sender, options) {
|
|
89
|
-
//
|
|
90
|
+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
90
91
|
this.startCapturing(options !== null && options !== void 0 ? options : this.defaultCaptureOptions);
|
|
91
92
|
this.startSending(sender);
|
|
92
93
|
}
|
|
@@ -98,13 +99,14 @@ class GumVideoCapturer {
|
|
|
98
99
|
}
|
|
99
100
|
this.updateLocalPreviewIntervalId = undefined;
|
|
100
101
|
}
|
|
102
|
+
// eslint-disable-next-line @typescript-eslint/require-await
|
|
101
103
|
setPreferredDevice(deviceId) {
|
|
102
104
|
return __awaiter(this, void 0, void 0, function* () {
|
|
103
105
|
this.preferredDeviceId = deviceId;
|
|
104
106
|
if (this.captureOptions) {
|
|
105
|
-
const captureOptions = this
|
|
106
|
-
const sender = this.sender;
|
|
107
|
+
const { captureOptions, sender } = this;
|
|
107
108
|
this.disable();
|
|
109
|
+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
108
110
|
this.startCapturing(captureOptions);
|
|
109
111
|
if (sender) {
|
|
110
112
|
this.startSending(sender);
|
|
@@ -122,7 +124,7 @@ class GumVideoCapturer {
|
|
|
122
124
|
getUserMedia(options) {
|
|
123
125
|
var _a;
|
|
124
126
|
// TODO: Figure out a better way to make typescript accept "mandatory".
|
|
125
|
-
|
|
127
|
+
const constraints = {
|
|
126
128
|
audio: false,
|
|
127
129
|
video: {
|
|
128
130
|
deviceId: (_a = options.preferredDeviceId) !== null && _a !== void 0 ? _a : this.preferredDeviceId,
|
|
@@ -203,7 +205,7 @@ class GumVideoCapturer {
|
|
|
203
205
|
}
|
|
204
206
|
index_1.RingRTC.logInfo('stopCapturing()');
|
|
205
207
|
this.captureOptions = undefined;
|
|
206
|
-
if (
|
|
208
|
+
if (this.mediaStream) {
|
|
207
209
|
for (const track of this.mediaStream.getVideoTracks()) {
|
|
208
210
|
// Make the light turn off faster
|
|
209
211
|
track.stop();
|
|
@@ -216,7 +218,7 @@ class GumVideoCapturer {
|
|
|
216
218
|
if (this.sender === sender) {
|
|
217
219
|
return;
|
|
218
220
|
}
|
|
219
|
-
if (
|
|
221
|
+
if (this.sender) {
|
|
220
222
|
// If we're replacing an existing sender, make sure we stop the
|
|
221
223
|
// current setInterval loop before starting another one.
|
|
222
224
|
this.stopSending();
|
|
@@ -233,7 +235,7 @@ class GumVideoCapturer {
|
|
|
233
235
|
}
|
|
234
236
|
if (track.readyState === 'ended') {
|
|
235
237
|
this.stopCapturing();
|
|
236
|
-
index_1.RingRTC.logError(
|
|
238
|
+
index_1.RingRTC.logError('spawnSender(): Video track ended before spawning sender');
|
|
237
239
|
return;
|
|
238
240
|
}
|
|
239
241
|
const reader = new MediaStreamTrackProcessor({
|
|
@@ -241,10 +243,11 @@ class GumVideoCapturer {
|
|
|
241
243
|
}).readable.getReader();
|
|
242
244
|
const buffer = Buffer.alloc(exports.MAX_VIDEO_CAPTURE_BUFFER_SIZE);
|
|
243
245
|
this.spawnedSenderRunning = true;
|
|
246
|
+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
244
247
|
(() => __awaiter(this, void 0, void 0, function* () {
|
|
245
248
|
var _a;
|
|
246
249
|
try {
|
|
247
|
-
while (
|
|
250
|
+
while (mediaStream == this.mediaStream) {
|
|
248
251
|
const { done, value: frame } = yield reader.read();
|
|
249
252
|
if (done) {
|
|
250
253
|
break;
|
|
@@ -258,7 +261,10 @@ class GumVideoCapturer {
|
|
|
258
261
|
index_1.RingRTC.logWarn(`Unsupported video frame format: ${frame.format}`);
|
|
259
262
|
break;
|
|
260
263
|
}
|
|
261
|
-
frame.copyTo(buffer);
|
|
264
|
+
yield frame.copyTo(buffer);
|
|
265
|
+
if (sender !== this.sender) {
|
|
266
|
+
break;
|
|
267
|
+
}
|
|
262
268
|
sender.sendVideoFrame(frame.codedWidth, frame.codedHeight, format, buffer);
|
|
263
269
|
}
|
|
264
270
|
catch (e) {
|
|
@@ -295,7 +301,7 @@ class GumVideoCapturer {
|
|
|
295
301
|
if (localPreview.srcObject === mediaStream) {
|
|
296
302
|
return;
|
|
297
303
|
}
|
|
298
|
-
if (mediaStream) {
|
|
304
|
+
if (mediaStream && this.captureOptions) {
|
|
299
305
|
localPreview.srcObject = mediaStream;
|
|
300
306
|
if (localPreview.width === 0) {
|
|
301
307
|
localPreview.width = this.captureOptions.maxWidth;
|
|
@@ -327,7 +333,7 @@ class CanvasVideoRenderer {
|
|
|
327
333
|
if (this.source === source) {
|
|
328
334
|
return;
|
|
329
335
|
}
|
|
330
|
-
if (
|
|
336
|
+
if (this.source) {
|
|
331
337
|
// If we're replacing an existing source, make sure we stop the
|
|
332
338
|
// current rAF loop before starting another one.
|
|
333
339
|
if (this.rafId) {
|
|
@@ -17,6 +17,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
17
17
|
};
|
|
18
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
19
|
exports.CallingClass = void 0;
|
|
20
|
+
/* eslint-disable no-console, @typescript-eslint/require-await, @typescript-eslint/no-unused-vars */
|
|
20
21
|
const Service_1 = require("../ringrtc/Service");
|
|
21
22
|
const index_1 = require("../index");
|
|
22
23
|
const long_1 = __importDefault(require("long"));
|
|
@@ -38,14 +39,14 @@ class CallingClass {
|
|
|
38
39
|
}
|
|
39
40
|
setupCallCallbacks(call) {
|
|
40
41
|
// eslint-disable-next-line no-param-reassign
|
|
41
|
-
call.handleStateChanged = () =>
|
|
42
|
+
call.handleStateChanged = () => {
|
|
42
43
|
(0, Utils_1.log)('handleCallStateChanged');
|
|
43
44
|
(0, Utils_1.log)(`call.state === ${call.state}`);
|
|
44
45
|
if (call.state === Service_1.CallState.Ended) {
|
|
45
46
|
(0, Utils_1.log)(`call.endedReason === ${call.endedReason}`);
|
|
46
47
|
this._call = undefined;
|
|
47
48
|
}
|
|
48
|
-
}
|
|
49
|
+
};
|
|
49
50
|
// eslint-disable-next-line no-param-reassign
|
|
50
51
|
call.handleRemoteVideoEnabled = () => {
|
|
51
52
|
(0, Utils_1.log)('handleRemoteVideoEnabled');
|
|
@@ -59,7 +60,7 @@ class CallingClass {
|
|
|
59
60
|
// Callbacks
|
|
60
61
|
handleOutgoingSignaling(remoteUserId, message, urgency) {
|
|
61
62
|
return __awaiter(this, void 0, void 0, function* () {
|
|
62
|
-
(0, Utils_1.log)(
|
|
63
|
+
(0, Utils_1.log)(`handleOutgoingSignaling remoteUserId: ${remoteUserId}`);
|
|
63
64
|
return true;
|
|
64
65
|
});
|
|
65
66
|
}
|
|
@@ -79,65 +80,49 @@ class CallingClass {
|
|
|
79
80
|
});
|
|
80
81
|
}
|
|
81
82
|
handleAutoEndedIncomingCallRequest(callId, remoteUserId, reason, ageInSeconds, wasVideoCall, receivedAtCounter) {
|
|
82
|
-
|
|
83
|
-
(0, Utils_1.log)('handleAutoEndedIncomingCallRequest');
|
|
84
|
-
});
|
|
83
|
+
(0, Utils_1.log)('handleAutoEndedIncomingCallRequest');
|
|
85
84
|
}
|
|
86
85
|
handleLogMessage(level, fileName, line, message) {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
}
|
|
104
|
-
});
|
|
86
|
+
switch (level) {
|
|
87
|
+
case Service_1.CallLogLevel.Info:
|
|
88
|
+
// FgGray
|
|
89
|
+
console.log(`\x1b[90m${fileName}:${line} ${message}\x1b[0m`);
|
|
90
|
+
break;
|
|
91
|
+
case Service_1.CallLogLevel.Warn:
|
|
92
|
+
// FgYellow
|
|
93
|
+
console.warn(`\x1b[33m${fileName}:${line} ${message}\x1b[0m`);
|
|
94
|
+
break;
|
|
95
|
+
case Service_1.CallLogLevel.Error:
|
|
96
|
+
// FgRed
|
|
97
|
+
console.error(`\x1b[31m${fileName}:${line} ${message}\x1b[0m`);
|
|
98
|
+
break;
|
|
99
|
+
default:
|
|
100
|
+
break;
|
|
101
|
+
}
|
|
105
102
|
}
|
|
106
103
|
handleSendHttpRequest(requestId, url, method, headers, body) {
|
|
107
|
-
|
|
108
|
-
(0, Utils_1.log)('handleSendHttpRequest');
|
|
109
|
-
});
|
|
104
|
+
(0, Utils_1.log)('handleSendHttpRequest');
|
|
110
105
|
}
|
|
111
106
|
handleSendCallMessage(recipient, data, urgency) {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
return true;
|
|
115
|
-
});
|
|
107
|
+
(0, Utils_1.log)('handleSendCallMessage');
|
|
108
|
+
return true;
|
|
116
109
|
}
|
|
117
110
|
handleSendCallMessageToGroup(groupIdBytes, data, urgency) {
|
|
118
|
-
|
|
119
|
-
(0, Utils_1.log)('handleSendCallMessageToGroup');
|
|
120
|
-
});
|
|
111
|
+
(0, Utils_1.log)('handleSendCallMessageToGroup');
|
|
121
112
|
}
|
|
122
113
|
handleGroupCallRingUpdate(groupIdBytes, ringId, ringerBytes, update) {
|
|
123
|
-
|
|
124
|
-
(0, Utils_1.log)('handleGroupCallRingUpdate');
|
|
125
|
-
});
|
|
114
|
+
(0, Utils_1.log)('handleGroupCallRingUpdate');
|
|
126
115
|
}
|
|
127
116
|
////////////////////////////////////////////////////////////////////////////////
|
|
128
117
|
// Support
|
|
129
118
|
getCallSettings(isIncoming) {
|
|
130
119
|
return __awaiter(this, void 0, void 0, function* () {
|
|
131
120
|
if (isIncoming) {
|
|
132
|
-
(0, Utils_1.log)(
|
|
133
|
-
this._delayIncomingCallSettingsRequest.toString() +
|
|
134
|
-
'ms');
|
|
121
|
+
(0, Utils_1.log)(`getCallSettings delayed by ${this._delayIncomingCallSettingsRequest}ms`);
|
|
135
122
|
yield (0, Utils_1.sleep)(this._delayIncomingCallSettingsRequest);
|
|
136
123
|
}
|
|
137
124
|
else {
|
|
138
|
-
(0, Utils_1.log)(
|
|
139
|
-
this._delayOutgoingCallSettingsRequest.toString() +
|
|
140
|
-
'ms');
|
|
125
|
+
(0, Utils_1.log)(`getCallSettings delayed by ${this._delayOutgoingCallSettingsRequest}ms`);
|
|
141
126
|
yield (0, Utils_1.sleep)(this._delayOutgoingCallSettingsRequest);
|
|
142
127
|
}
|
|
143
128
|
return {
|
|
@@ -179,7 +164,7 @@ class CallingClass {
|
|
|
179
164
|
return;
|
|
180
165
|
}
|
|
181
166
|
const call = index_1.RingRTC.startOutgoingCall(remoteUserId, false, this._localDeviceId);
|
|
182
|
-
(0, Utils_1.log)(
|
|
167
|
+
(0, Utils_1.log)(`Outgoing callId ${long_1.default.fromValue(call.callId)}`);
|
|
183
168
|
index_1.RingRTC.setOutgoingAudio(call.callId, true);
|
|
184
169
|
this._call = call;
|
|
185
170
|
this.setupCallCallbacks(call);
|
|
@@ -16,6 +16,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
16
16
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
17
17
|
};
|
|
18
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
+
/* eslint-disable @typescript-eslint/no-non-null-assertion */
|
|
19
20
|
const chai_1 = require("chai");
|
|
20
21
|
const chai_as_promised_1 = __importDefault(require("chai-as-promised"));
|
|
21
22
|
const crypto_1 = require("crypto");
|
|
@@ -64,9 +65,11 @@ describe('RingRTC', () => {
|
|
|
64
65
|
const age = 60 * 60;
|
|
65
66
|
try {
|
|
66
67
|
const { reason, ageSec: reportedAge } = yield new Promise((resolve, _reject) => {
|
|
68
|
+
/* eslint-disable @typescript-eslint/no-shadow */
|
|
67
69
|
index_1.RingRTC.handleAutoEndedIncomingCallRequest = (_callId, _remoteUserId, reason, ageSec) => {
|
|
68
70
|
resolve({ reason, ageSec });
|
|
69
71
|
};
|
|
72
|
+
/* eslint-enable @typescript-eslint/no-shadow */
|
|
70
73
|
index_1.RingRTC.handleCallingMessage('remote', null, 4, 2, age, 1, offer, Buffer.from([]), Buffer.from([]));
|
|
71
74
|
});
|
|
72
75
|
chai_1.assert.equal(reason, index_1.CallEndedReason.ReceivedOfferExpired);
|
|
@@ -87,9 +90,11 @@ describe('RingRTC', () => {
|
|
|
87
90
|
};
|
|
88
91
|
try {
|
|
89
92
|
const { reason, ageSec: reportedAge } = yield new Promise((resolve, _reject) => {
|
|
93
|
+
/* eslint-disable @typescript-eslint/no-shadow */
|
|
90
94
|
index_1.RingRTC.handleAutoEndedIncomingCallRequest = (_callId, _remoteUserId, reason, ageSec) => {
|
|
91
95
|
resolve({ reason, ageSec });
|
|
92
96
|
};
|
|
97
|
+
/* eslint-enable @typescript-eslint/no-shadow */
|
|
93
98
|
index_1.RingRTC.handleCallingMessage('remote', null, 4, 2, 10, 2, offer, Buffer.from([]), Buffer.from([]));
|
|
94
99
|
});
|
|
95
100
|
chai_1.assert.equal(reason, index_1.CallEndedReason.Declined); // because we didn't set handleIncomingCall.
|
|
@@ -108,7 +113,7 @@ describe('RingRTC', () => {
|
|
|
108
113
|
chai_1.assert.isNotNull(index_1.RingRTC, "RingRTC didn't initialize!");
|
|
109
114
|
});
|
|
110
115
|
it('can establish outgoing call', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
111
|
-
|
|
116
|
+
const calling = new CallingClass_1.CallingClass(user1_name, user1_id);
|
|
112
117
|
calling.initialize();
|
|
113
118
|
initializeSpies();
|
|
114
119
|
yield calling.startOutgoingDirectCall(user2_id);
|
|
@@ -125,7 +130,7 @@ describe('RingRTC', () => {
|
|
|
125
130
|
yield (0, Utils_1.sleep)(100);
|
|
126
131
|
}));
|
|
127
132
|
it('can establish incoming call', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
128
|
-
|
|
133
|
+
const calling = new CallingClass_1.CallingClass(user1_name, user1_id);
|
|
129
134
|
calling.initialize();
|
|
130
135
|
initializeSpies();
|
|
131
136
|
// Generate incoming calling message
|
|
@@ -146,25 +151,25 @@ describe('RingRTC', () => {
|
|
|
146
151
|
chai_1.assert.equal(index_1.CallState.Ended, index_1.RingRTC.call.state);
|
|
147
152
|
}));
|
|
148
153
|
it('outgoing call wins glare when incoming call id is lower', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
149
|
-
|
|
154
|
+
const calling = new CallingClass_1.CallingClass(user1_name, user1_id);
|
|
150
155
|
calling.initialize();
|
|
151
156
|
initializeSpies();
|
|
152
157
|
yield runGlareScenario(calling, true, 0, 0);
|
|
153
158
|
}));
|
|
154
159
|
it('outgoing call wins glare when incoming call id is lower even when outgoing call settings are delayed', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
155
|
-
|
|
160
|
+
const calling = new CallingClass_1.CallingClass(user1_name, user1_id);
|
|
156
161
|
calling.initialize();
|
|
157
162
|
initializeSpies();
|
|
158
163
|
yield runGlareScenario(calling, true, 0, 1000);
|
|
159
164
|
}));
|
|
160
165
|
it('outgoing call loses glare when incoming call id is higher even when outgoing call settings are delayed', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
161
|
-
|
|
166
|
+
const calling = new CallingClass_1.CallingClass(user1_name, user1_id);
|
|
162
167
|
calling.initialize();
|
|
163
168
|
initializeSpies();
|
|
164
169
|
yield runGlareScenario(calling, false, 0, 1000);
|
|
165
170
|
}));
|
|
166
171
|
it('outgoing call loses glare when incoming call id is higher', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
167
|
-
|
|
172
|
+
const calling = new CallingClass_1.CallingClass(user1_name, user1_id);
|
|
168
173
|
calling.initialize();
|
|
169
174
|
initializeSpies();
|
|
170
175
|
yield runGlareScenario(calling, false, 0, 0);
|
|
@@ -176,12 +181,12 @@ describe('RingRTC', () => {
|
|
|
176
181
|
const outgoingCallLatch = (0, Utils_1.countDownLatch)(1);
|
|
177
182
|
calling
|
|
178
183
|
.startOutgoingDirectCall(user2_id)
|
|
179
|
-
.then(
|
|
184
|
+
.then(_result => {
|
|
180
185
|
(0, Utils_1.log)('Outgoing call succeeded as expected');
|
|
181
186
|
outgoingCallLatch.countDown();
|
|
182
187
|
})
|
|
183
188
|
.catch(e => {
|
|
184
|
-
chai_1.assert.fail(
|
|
189
|
+
chai_1.assert.fail(`Outgoing call should not have failed: ${e}`);
|
|
185
190
|
});
|
|
186
191
|
yield outgoingCallLatch.finished;
|
|
187
192
|
const outgoingCallId = long_1.default.fromValue(index_1.RingRTC.call.callId);
|
package/dist/test/Utils.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export declare function countDownLatch(count: number): {
|
|
2
2
|
countDown: () => void;
|
|
3
|
-
finished: Promise<
|
|
3
|
+
finished: Promise<void>;
|
|
4
4
|
};
|
|
5
5
|
export declare function log(line: string): void;
|
|
6
|
-
export declare
|
|
6
|
+
export declare function sleep(timeout: number): Promise<void>;
|
|
7
7
|
export declare function uuidToBytes(uuid: string): Uint8Array;
|
package/dist/test/Utils.js
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
//
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
exports.uuidToBytes = exports.sleep = exports.log = exports.countDownLatch = void 0;
|
|
8
|
+
/* eslint-disable no-console */
|
|
8
9
|
const lodash_1 = require("lodash");
|
|
9
10
|
const chai_1 = require("chai");
|
|
10
11
|
function countDownLatch(count) {
|
|
@@ -32,7 +33,7 @@ function log(line) {
|
|
|
32
33
|
console.log(`\x1b[43m${line}\x1b[0m`);
|
|
33
34
|
}
|
|
34
35
|
exports.log = log;
|
|
35
|
-
|
|
36
|
+
function sleep(timeout) {
|
|
36
37
|
return new Promise(resolve => {
|
|
37
38
|
setTimeout(() => {
|
|
38
39
|
// BgBlue
|
|
@@ -40,7 +41,7 @@ let sleep = (timeout) => {
|
|
|
40
41
|
resolve();
|
|
41
42
|
}, timeout);
|
|
42
43
|
});
|
|
43
|
-
}
|
|
44
|
+
}
|
|
44
45
|
exports.sleep = sleep;
|
|
45
46
|
function uuidToBytes(uuid) {
|
|
46
47
|
if (uuid.length !== 36) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@signalapp/ringrtc",
|
|
3
|
-
"version": "2.25.
|
|
3
|
+
"version": "2.25.2",
|
|
4
4
|
"description": "Signal Messenger voice and video calling library.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -14,13 +14,13 @@
|
|
|
14
14
|
"test": "electron-mocha --renderer --recursive dist/test --timeout 10000",
|
|
15
15
|
"eslint": "eslint --cache .",
|
|
16
16
|
"lint": "yarn format --list-different && yarn eslint",
|
|
17
|
-
"format": "prettier --write
|
|
17
|
+
"format": "prettier --write .",
|
|
18
18
|
"install": "node scripts/fetch-prebuild.js",
|
|
19
19
|
"prepublishOnly": "node scripts/prepublish.js"
|
|
20
20
|
},
|
|
21
21
|
"config": {
|
|
22
22
|
"prebuildUrl": "https://build-artifacts.signal.org/libraries/ringrtc-desktop-build-v${npm_package_version}.tar.gz",
|
|
23
|
-
"prebuildChecksum": "
|
|
23
|
+
"prebuildChecksum": "b953fd21380c7025b5004bd0db99274737be1aeec1c76133f08568adcfd5adaf"
|
|
24
24
|
},
|
|
25
25
|
"author": "",
|
|
26
26
|
"license": "AGPL-3.0-only",
|
|
@@ -35,7 +35,6 @@
|
|
|
35
35
|
"@types/mocha": "10.0.1",
|
|
36
36
|
"@types/node": "18.14.0",
|
|
37
37
|
"@types/offscreencanvas": "^2019.7.0",
|
|
38
|
-
"@types/react": "18.0.28",
|
|
39
38
|
"@types/sinon-chai": "^3.2.9",
|
|
40
39
|
"chai": "4.3.7",
|
|
41
40
|
"chai-as-promised": "^7.1.1",
|
|
@@ -47,7 +46,6 @@
|
|
|
47
46
|
"eslint-plugin-import": "2.27.5",
|
|
48
47
|
"eslint-plugin-mocha": "10.1.0",
|
|
49
48
|
"eslint-plugin-more": "1.0.5",
|
|
50
|
-
"eslint-plugin-react": "7.32.2",
|
|
51
49
|
"long": "5.2.1",
|
|
52
50
|
"mocha": "10.2.0",
|
|
53
51
|
"prettier": "^2.8.4",
|