From 38cdb9b2897a7dc14c371efd72a8707ab38f8c4f Mon Sep 17 00:00:00 2001 From: Jim Gustafson Date: Fri, 3 Dec 2021 12:22:58 -0800 Subject: [PATCH] Update to RingRTC v2.16.0 --- package.json | 2 +- ts/services/calling.ts | 151 ++++++++++++++++++++++------------------- yarn.lock | 6 +- 3 files changed, 84 insertions(+), 75 deletions(-) diff --git a/package.json b/package.json index ff76ee299..63b13f27f 100644 --- a/package.json +++ b/package.json @@ -157,7 +157,7 @@ "redux-ts-utils": "3.2.2", "reselect": "4.1.2", "rimraf": "2.6.2", - "ringrtc": "https://github.com/signalapp/signal-ringrtc-node.git#7a17d31bc0d4e8fadb1920b5fef9417ff5cf4d0a", + "ringrtc": "https://github.com/signalapp/signal-ringrtc-node.git#7564aff3d10f7c9b70134a0dc8acdfe8512f75e1", "rotating-file-stream": "2.1.5", "sanitize.css": "11.0.0", "semver": "5.4.1", diff --git a/ts/services/calling.ts b/ts/services/calling.ts index 178e508f5..6f7ea01c4 100644 --- a/ts/services/calling.ts +++ b/ts/services/calling.ts @@ -602,94 +602,103 @@ export class CallingClass { let updateMessageState = GroupCallUpdateMessageState.SentNothing; let isRequestingMembershipProof = false; - const outerGroupCall = RingRTC.getGroupCall(groupIdBuffer, this.sfuUrl, { - onLocalDeviceStateChanged: groupCall => { - const localDeviceState = groupCall.getLocalDeviceState(); - const { eraId } = groupCall.getPeekInfo() || {}; - - if (localDeviceState.connectionState === ConnectionState.NotConnected) { - // NOTE: This assumes that only one call is active at a time. For example, if - // there are two calls using the camera, this will disable both of them. - // That's fine for now, but this will break if that assumption changes. - this.disableLocalVideo(); - - delete this.callsByConversation[conversationId]; + const outerGroupCall = RingRTC.getGroupCall( + groupIdBuffer, + this.sfuUrl, + Buffer.alloc(0), + { + onLocalDeviceStateChanged: groupCall => { + const localDeviceState = groupCall.getLocalDeviceState(); + const { eraId } = groupCall.getPeekInfo() || {}; if ( - updateMessageState === GroupCallUpdateMessageState.SentJoin && - eraId + localDeviceState.connectionState === ConnectionState.NotConnected ) { - updateMessageState = GroupCallUpdateMessageState.SentLeft; - this.sendGroupCallUpdateMessage(conversationId, eraId); - } - } else { - this.callsByConversation[conversationId] = groupCall; - - // NOTE: This assumes only one active call at a time. See comment above. - if (localDeviceState.videoMuted) { + // NOTE: This assumes that only one call is active at a time. For example, if + // there are two calls using the camera, this will disable both of them. + // That's fine for now, but this will break if that assumption changes. this.disableLocalVideo(); + + delete this.callsByConversation[conversationId]; + + if ( + updateMessageState === GroupCallUpdateMessageState.SentJoin && + eraId + ) { + updateMessageState = GroupCallUpdateMessageState.SentLeft; + this.sendGroupCallUpdateMessage(conversationId, eraId); + } } else { - this.videoCapturer.enableCaptureAndSend(groupCall); + this.callsByConversation[conversationId] = groupCall; + + // NOTE: This assumes only one active call at a time. See comment above. + if (localDeviceState.videoMuted) { + this.disableLocalVideo(); + } else { + this.videoCapturer.enableCaptureAndSend(groupCall); + } + + if ( + updateMessageState === GroupCallUpdateMessageState.SentNothing && + localDeviceState.joinState === JoinState.Joined && + eraId + ) { + updateMessageState = GroupCallUpdateMessageState.SentJoin; + this.sendGroupCallUpdateMessage(conversationId, eraId); + } } + this.syncGroupCallToRedux(conversationId, groupCall); + }, + onRemoteDeviceStatesChanged: groupCall => { + this.syncGroupCallToRedux(conversationId, groupCall); + }, + onPeekChanged: groupCall => { + const localDeviceState = groupCall.getLocalDeviceState(); + const { eraId } = groupCall.getPeekInfo() || {}; if ( updateMessageState === GroupCallUpdateMessageState.SentNothing && + localDeviceState.connectionState !== ConnectionState.NotConnected && localDeviceState.joinState === JoinState.Joined && eraId ) { updateMessageState = GroupCallUpdateMessageState.SentJoin; this.sendGroupCallUpdateMessage(conversationId, eraId); } - } - this.syncGroupCallToRedux(conversationId, groupCall); - }, - onRemoteDeviceStatesChanged: groupCall => { - this.syncGroupCallToRedux(conversationId, groupCall); - }, - onPeekChanged: groupCall => { - const localDeviceState = groupCall.getLocalDeviceState(); - const { eraId } = groupCall.getPeekInfo() || {}; - if ( - updateMessageState === GroupCallUpdateMessageState.SentNothing && - localDeviceState.connectionState !== ConnectionState.NotConnected && - localDeviceState.joinState === JoinState.Joined && - eraId - ) { - updateMessageState = GroupCallUpdateMessageState.SentJoin; - this.sendGroupCallUpdateMessage(conversationId, eraId); - } - - this.updateCallHistoryForGroupCall( - conversationId, - groupCall.getPeekInfo() - ); - this.syncGroupCallToRedux(conversationId, groupCall); - }, - async requestMembershipProof(groupCall) { - if (isRequestingMembershipProof) { - return; - } - isRequestingMembershipProof = true; - try { - const proof = await fetchMembershipProof({ - publicParams, - secretParams, - }); - if (proof) { - groupCall.setMembershipProof(Buffer.from(Bytes.fromString(proof))); + this.updateCallHistoryForGroupCall( + conversationId, + groupCall.getPeekInfo() + ); + this.syncGroupCallToRedux(conversationId, groupCall); + }, + async requestMembershipProof(groupCall) { + if (isRequestingMembershipProof) { + return; } - } catch (err) { - log.error('Failed to fetch membership proof', err); - } finally { - isRequestingMembershipProof = false; - } - }, - requestGroupMembers: groupCall => { - groupCall.setGroupMembers(this.getGroupCallMembers(conversationId)); - }, - onEnded: noop, - }); + isRequestingMembershipProof = true; + try { + const proof = await fetchMembershipProof({ + publicParams, + secretParams, + }); + if (proof) { + groupCall.setMembershipProof( + Buffer.from(Bytes.fromString(proof)) + ); + } + } catch (err) { + log.error('Failed to fetch membership proof', err); + } finally { + isRequestingMembershipProof = false; + } + }, + requestGroupMembers: groupCall => { + groupCall.setGroupMembers(this.getGroupCallMembers(conversationId)); + }, + onEnded: noop, + } + ); if (!outerGroupCall) { // This should be very rare, likely due to RingRTC not being able to get a lock diff --git a/yarn.lock b/yarn.lock index 059b76a30..f8890a500 100644 --- a/yarn.lock +++ b/yarn.lock @@ -15438,9 +15438,9 @@ rimraf@^3.0.0, rimraf@^3.0.2, rimraf@~3.0.2: dependencies: glob "^7.1.3" -"ringrtc@https://github.com/signalapp/signal-ringrtc-node.git#7a17d31bc0d4e8fadb1920b5fef9417ff5cf4d0a": - version "2.15.0" - resolved "https://github.com/signalapp/signal-ringrtc-node.git#7a17d31bc0d4e8fadb1920b5fef9417ff5cf4d0a" +"ringrtc@https://github.com/signalapp/signal-ringrtc-node.git#7564aff3d10f7c9b70134a0dc8acdfe8512f75e1": + version "2.16.0" + resolved "https://github.com/signalapp/signal-ringrtc-node.git#7564aff3d10f7c9b70134a0dc8acdfe8512f75e1" ripemd160@^2.0.0, ripemd160@^2.0.1: version "2.0.1"