chore: add MatrixSDKVoipException and some more logging
This commit is contained in:
parent
39a8b8ce89
commit
b5fb43af51
|
|
@ -23,7 +23,8 @@ abstract class CallBackend {
|
|||
type: type,
|
||||
);
|
||||
} else {
|
||||
throw ArgumentError('Invalid type: $type');
|
||||
throw MatrixSDKVoipException(
|
||||
'Invalid type: $type in CallBackend.fromJson');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -80,7 +80,8 @@ class LiveKitBackend extends CallBackend {
|
|||
final keyProvider = groupCall.voip.delegate.keyProvider;
|
||||
|
||||
if (keyProvider == null) {
|
||||
throw Exception('[VOIP] _ratchetKey called but KeyProvider was null');
|
||||
throw MatrixSDKVoipException(
|
||||
'_ratchetKey called but KeyProvider was null');
|
||||
}
|
||||
|
||||
final myKeys = _encryptionKeysMap[groupCall.localParticipant];
|
||||
|
|
|
|||
|
|
@ -87,8 +87,7 @@ class MeshBackend extends CallBackend {
|
|||
return await groupCall.voip.delegate.mediaDevices
|
||||
.getDisplayMedia(mediaConstraints);
|
||||
} catch (e, s) {
|
||||
Logs().e('[VOIP] _getDisplayMedia failed because,', e, s);
|
||||
rethrow;
|
||||
throw MatrixSDKVoipException('_getDisplayMedia failed', stackTrace: s);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -113,7 +112,7 @@ class MeshBackend extends CallBackend {
|
|||
/// init a peer call from group calls.
|
||||
Future<void> _initCall(GroupCallSession groupCall, CallSession call) async {
|
||||
if (call.remoteUserId == null) {
|
||||
throw Exception(
|
||||
throw MatrixSDKVoipException(
|
||||
'Cannot init call without proper invitee user and device Id');
|
||||
}
|
||||
|
||||
|
|
@ -156,7 +155,7 @@ class MeshBackend extends CallBackend {
|
|||
.indexWhere((element) => element.callId == existingCall.callId);
|
||||
|
||||
if (existingCallIndex == -1) {
|
||||
throw Exception('Couldn\'t find call to replace');
|
||||
throw MatrixSDKVoipException('Couldn\'t find call to replace');
|
||||
}
|
||||
|
||||
_callSessions.removeAt(existingCallIndex);
|
||||
|
|
@ -181,7 +180,7 @@ class MeshBackend extends CallBackend {
|
|||
Future<void> _disposeCall(GroupCallSession groupCall, CallSession call,
|
||||
CallErrorCode hangupReason) async {
|
||||
if (call.remoteUserId == null) {
|
||||
throw Exception(
|
||||
throw MatrixSDKVoipException(
|
||||
'Cannot init call without proper invitee user and device Id');
|
||||
}
|
||||
|
||||
|
|
@ -223,7 +222,7 @@ class MeshBackend extends CallBackend {
|
|||
Future<void> _onStreamsChanged(
|
||||
GroupCallSession groupCall, CallSession call) async {
|
||||
if (call.remoteUserId == null) {
|
||||
throw Exception(
|
||||
throw MatrixSDKVoipException(
|
||||
'Cannot init call without proper invitee user and device Id');
|
||||
}
|
||||
|
||||
|
|
@ -372,7 +371,8 @@ class MeshBackend extends CallBackend {
|
|||
(stream) => stream.participant.id == existingStream.participant.id);
|
||||
|
||||
if (streamIndex == -1) {
|
||||
throw Exception('Couldn\'t find screenshare stream to replace');
|
||||
throw MatrixSDKVoipException(
|
||||
'Couldn\'t find screenshare stream to replace');
|
||||
}
|
||||
|
||||
_screenshareStreams.replaceRange(streamIndex, 1, [replacementStream]);
|
||||
|
|
@ -390,7 +390,8 @@ class MeshBackend extends CallBackend {
|
|||
.indexWhere((stream) => stream.participant.id == stream.participant.id);
|
||||
|
||||
if (streamIndex == -1) {
|
||||
throw Exception('Couldn\'t find screenshare stream to remove');
|
||||
throw MatrixSDKVoipException(
|
||||
'Couldn\'t find screenshare stream to remove');
|
||||
}
|
||||
|
||||
_screenshareStreams.removeWhere(
|
||||
|
|
@ -451,7 +452,8 @@ class MeshBackend extends CallBackend {
|
|||
(stream) => stream.participant.id == existingStream.participant.id);
|
||||
|
||||
if (streamIndex == -1) {
|
||||
throw Exception('Couldn\'t find user media stream to replace');
|
||||
throw MatrixSDKVoipException(
|
||||
'Couldn\'t find user media stream to replace');
|
||||
}
|
||||
|
||||
_userMediaStreams.replaceRange(streamIndex, 1, [replacementStream]);
|
||||
|
|
@ -469,7 +471,8 @@ class MeshBackend extends CallBackend {
|
|||
(element) => element.participant.id == stream.participant.id);
|
||||
|
||||
if (streamIndex == -1) {
|
||||
throw Exception('Couldn\'t find user media stream to remove');
|
||||
throw MatrixSDKVoipException(
|
||||
'Couldn\'t find user media stream to remove');
|
||||
}
|
||||
|
||||
_userMediaStreams.removeWhere(
|
||||
|
|
@ -527,7 +530,7 @@ class MeshBackend extends CallBackend {
|
|||
Future<WrappedMediaStream?> initLocalStream(GroupCallSession groupCall,
|
||||
{WrappedMediaStream? stream}) async {
|
||||
if (groupCall.state != GroupCallState.localCallFeedUninitialized) {
|
||||
throw Exception(
|
||||
throw MatrixSDKVoipException(
|
||||
'Cannot initialize local call feed in the ${groupCall.state} state.');
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -928,9 +928,10 @@ class CallSession {
|
|||
if (sender.track != null && sender.track!.kind == 'audio') {
|
||||
await sender.dtmfSender.insertDTMF(tones);
|
||||
return;
|
||||
} else {
|
||||
Logs().w('[VOIP] Unable to find a track to send DTMF on');
|
||||
}
|
||||
}
|
||||
Logs().e('[VOIP] Unable to find a track to send DTMF on');
|
||||
}
|
||||
|
||||
Future<void> terminate(
|
||||
|
|
|
|||
|
|
@ -112,7 +112,7 @@ class GroupCallSession {
|
|||
Future<void> enter({WrappedMediaStream? stream}) async {
|
||||
if (!(state == GroupCallState.localCallFeedUninitialized ||
|
||||
state == GroupCallState.localCallFeedInitialized)) {
|
||||
throw Exception('Cannot enter call in the $state state');
|
||||
throw MatrixSDKVoipException('Cannot enter call in the $state state');
|
||||
}
|
||||
|
||||
if (state == GroupCallState.localCallFeedUninitialized) {
|
||||
|
|
|
|||
|
|
@ -128,8 +128,9 @@ extension FamedlyCallMemberEventsExtension on Room {
|
|||
newContent,
|
||||
);
|
||||
} else {
|
||||
throw Exception(
|
||||
'[VOIP] User is not allowed to send famedly call member events in room');
|
||||
throw MatrixSDKVoipException(
|
||||
'User ${client.userID}:${client.deviceID} is not allowed to send famedly call member events in room $id, canJoinGroupCall: $canJoinGroupCall, room.canJoinGroupCall: $groupCallsEnabledForEveryone',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -165,3 +166,13 @@ bool isValidMemEvent(Map<String, Object?> event) {
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
class MatrixSDKVoipException implements Exception {
|
||||
final String cause;
|
||||
final StackTrace? stackTrace;
|
||||
|
||||
MatrixSDKVoipException(this.cause, {this.stackTrace});
|
||||
|
||||
@override
|
||||
String toString() => '[VOIP] $cause, ${super.toString()}, $stackTrace';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -772,8 +772,9 @@ class VoIP {
|
|||
|
||||
if (groupCall != null) {
|
||||
if (!room.canJoinGroupCall) {
|
||||
throw Exception(
|
||||
'[VOIP] User is not allowed to join famedly calls in the room');
|
||||
throw MatrixSDKVoipException(
|
||||
'User ${client.userID}:${client.deviceID} is not allowed to join famedly calls in room ${room.id}, canJoinGroupCall: ${room.canJoinGroupCall}, room.canJoinGroupCall: ${room.groupCallsEnabledForEveryone}',
|
||||
);
|
||||
}
|
||||
return groupCall;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue