feat: make voip key generator public

with this you can now send the key before joining the call to the participants, make sure to call onMemberStateChanged first to ensure groupCall.participants is populated
This commit is contained in:
td 2024-05-22 18:19:18 +05:30
parent 162a4f31f3
commit d313cbb18e
No known key found for this signature in database
GPG Key ID: 62A30523D4D6CE28
2 changed files with 5 additions and 11 deletions

View File

@ -56,7 +56,7 @@ class LiveKitBackend extends CallBackend {
/// used on first join and when someone leaves
///
/// also does the sending for you
Future<void> _makeNewSenderKey(
Future<void> makeNewSenderKey(
GroupCallSession groupCall, bool delayBeforeUsingKeyOurself) async {
final key = secureRandomBytes(32);
final keyIndex = _getNewEncryptionKeyIndex();
@ -87,7 +87,7 @@ class LiveKitBackend extends CallBackend {
final myKeys = _encryptionKeysMap[groupCall.localParticipant];
if (myKeys == null || myKeys.isEmpty) {
await _makeNewSenderKey(groupCall, false);
await makeNewSenderKey(groupCall, false);
return;
}
@ -186,7 +186,7 @@ class LiveKitBackend extends CallBackend {
if (myKeys == null || myLatestKey == null) {
Logs().w(
'[VOIP E2EE] _sendEncryptionKeysEvent Tried to send encryption keys event but no keys found!');
await _makeNewSenderKey(groupCall, false);
await makeNewSenderKey(groupCall, false);
await _sendEncryptionKeysEvent(
groupCall,
keyIndex,
@ -392,7 +392,7 @@ class LiveKitBackend extends CallBackend {
if (groupCall.voip.enableSFUE2EEKeyRatcheting) {
await _ratchetLocalParticipantKey(groupCall, anyJoined);
} else {
await _makeNewSenderKey(groupCall, true);
await makeNewSenderKey(groupCall, true);
}
}
@ -409,7 +409,7 @@ class LiveKitBackend extends CallBackend {
}
_memberLeaveEncKeyRotateDebounceTimer =
Timer(CallTimeouts.makeKeyDelay, () async {
await _makeNewSenderKey(groupCall, true);
await makeNewSenderKey(groupCall, true);
});
}

View File

@ -199,12 +199,6 @@ class GroupCallSession {
/// compltetely rebuilds the local _participants list
Future<void> onMemberStateChanged() async {
if (state != GroupCallState.entered) {
Logs().d(
'[VOIP] early return onMemberStateChanged, group call state is not Entered. Actual state: ${state.toString()} ');
return;
}
// The member events may be received for another room, which we will ignore.
final mems =
room.getCallMembershipsFromRoom().values.expand((element) => element);