Line data Source code
1 : import 'package:matrix/matrix.dart';
2 :
3 : /// https://github.com/matrix-org/matrix-doc/pull/2746
4 : /// version 1
5 : const String voipProtoVersion = '1';
6 :
7 : class CallTimeouts {
8 : /// The default life time for call events, in millisecond.
9 : final Duration defaultCallEventLifetime;
10 :
11 : /// The length of time a call can be ringing for.
12 : final Duration callInviteLifetime;
13 :
14 : /// The delay for ice gathering.
15 : final Duration iceGatheringDelay;
16 :
17 : /// Delay before createOffer.
18 : final Duration delayBeforeOffer;
19 :
20 : /// How often to update the expiresTs
21 : final Duration updateExpireTsTimerDuration;
22 :
23 : /// the expiresTs bump
24 : final Duration expireTsBumpDuration;
25 :
26 : /// Update the active speaker value
27 : final Duration activeSpeakerInterval;
28 :
29 : // source: element call?
30 : /// A delay after a member leaves before we create and publish a new key, because people
31 : /// tend to leave calls at the same time
32 : final Duration makeKeyOnLeaveDelay;
33 :
34 : /// A delay used for joins, only creates new keys if last new created key was before
35 : /// $makeKeyDelay duration, or it was recently made and it's safe to send that
36 : /// The bigger this is the easier key sharing would be, but also less secure
37 : /// Not used if ratcheting is enabled
38 : final Duration makeKeyOnJoinDelay;
39 :
40 : /// The delay between creating and sending a new key and starting to encrypt with it. This gives others
41 : /// a chance to receive the new key to minimise the chance they don't get media they can't decrypt.
42 : /// The total time between a member leaving and the call switching to new keys is therefore
43 : /// makeKeyDelay + useKeyDelay
44 : final Duration useKeyDelay;
45 :
46 : /// After how long the homeserver should send the delayed leave event which
47 : /// gracefully leaves you from the call
48 : final Duration delayedEventApplyLeave;
49 :
50 : /// How often the delayed event should be restarted on the homeserver
51 : final Duration delayedEventRestart;
52 :
53 6 : CallTimeouts({
54 : this.defaultCallEventLifetime = const Duration(seconds: 10),
55 : this.callInviteLifetime = const Duration(seconds: 60),
56 : this.iceGatheringDelay = const Duration(milliseconds: 200),
57 : this.delayBeforeOffer = const Duration(milliseconds: 100),
58 : this.updateExpireTsTimerDuration = const Duration(minutes: 2),
59 : this.expireTsBumpDuration = const Duration(minutes: 6),
60 : this.activeSpeakerInterval = const Duration(seconds: 5),
61 : this.makeKeyOnLeaveDelay = const Duration(seconds: 4),
62 : this.makeKeyOnJoinDelay = const Duration(seconds: 8),
63 : this.useKeyDelay = const Duration(seconds: 4),
64 : this.delayedEventApplyLeave = const Duration(seconds: 18),
65 : this.delayedEventRestart = const Duration(seconds: 4),
66 : });
67 : }
68 :
69 : class CallConstants {
70 120 : static final callEventsRegxp = RegExp(
71 : r'm.call.|org.matrix.call.|org.matrix.msc3401.call.|com.famedly.call.|m.room.redaction',
72 : );
73 :
74 : static const callEndedEventTypes = {
75 : EventTypes.CallAnswer,
76 : EventTypes.CallHangup,
77 : EventTypes.CallReject,
78 : EventTypes.CallReplaces,
79 : };
80 : static const omitWhenCallEndedTypes = {
81 : EventTypes.CallInvite,
82 : EventTypes.CallCandidates,
83 : EventTypes.CallNegotiate,
84 : EventTypes.CallSDPStreamMetadataChanged,
85 : EventTypes.CallSDPStreamMetadataChangedPrefix,
86 : };
87 :
88 : static const updateExpireTsTimerDuration = Duration(seconds: 15);
89 : static const expireTsBumpDuration = Duration(seconds: 45);
90 : static const activeSpeakerInterval = Duration(seconds: 5);
91 : static const ephemeralReactionTimeout = Duration(seconds: 2);
92 : }
|