@unwanted/matrix-sdk-mini 34.12.0 → 34.13.0

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.
Files changed (698) hide show
  1. package/git-revision.txt +1 -1
  2. package/lib/@types/event.d.ts +0 -19
  3. package/lib/@types/event.d.ts.map +1 -1
  4. package/lib/@types/event.js.map +1 -1
  5. package/lib/@types/global.d.js +0 -2
  6. package/lib/@types/global.d.js.map +1 -1
  7. package/lib/autodiscovery.d.ts +1 -1
  8. package/lib/autodiscovery.d.ts.map +1 -1
  9. package/lib/autodiscovery.js.map +1 -1
  10. package/lib/base64.d.ts +3 -6
  11. package/lib/base64.d.ts.map +1 -1
  12. package/lib/base64.js +43 -36
  13. package/lib/base64.js.map +1 -1
  14. package/lib/browser-index.d.ts.map +1 -1
  15. package/lib/browser-index.js +0 -11
  16. package/lib/browser-index.js.map +1 -1
  17. package/lib/client.d.ts +2 -1298
  18. package/lib/client.d.ts.map +1 -1
  19. package/lib/client.js +348 -2967
  20. package/lib/client.js.map +1 -1
  21. package/lib/digest.d.ts +2 -2
  22. package/lib/digest.d.ts.map +1 -1
  23. package/lib/digest.js +2 -2
  24. package/lib/digest.js.map +1 -1
  25. package/lib/embedded.d.ts +0 -22
  26. package/lib/embedded.d.ts.map +1 -1
  27. package/lib/embedded.js +58 -168
  28. package/lib/embedded.js.map +1 -1
  29. package/lib/event-mapper.d.ts.map +1 -1
  30. package/lib/event-mapper.js +0 -4
  31. package/lib/event-mapper.js.map +1 -1
  32. package/lib/matrix.d.ts +0 -25
  33. package/lib/matrix.d.ts.map +1 -1
  34. package/lib/matrix.js +1 -30
  35. package/lib/matrix.js.map +1 -1
  36. package/lib/models/MSC3089Branch.d.ts.map +1 -1
  37. package/lib/models/MSC3089Branch.js +0 -3
  38. package/lib/models/MSC3089Branch.js.map +1 -1
  39. package/lib/models/event-timeline-set.d.ts +6 -10
  40. package/lib/models/event-timeline-set.d.ts.map +1 -1
  41. package/lib/models/event-timeline-set.js +28 -36
  42. package/lib/models/event-timeline-set.js.map +1 -1
  43. package/lib/models/event-timeline.d.ts +7 -2
  44. package/lib/models/event-timeline.d.ts.map +1 -1
  45. package/lib/models/event-timeline.js +8 -9
  46. package/lib/models/event-timeline.js.map +1 -1
  47. package/lib/models/event.d.ts +1 -95
  48. package/lib/models/event.d.ts.map +1 -1
  49. package/lib/models/event.js +11 -281
  50. package/lib/models/event.js.map +1 -1
  51. package/lib/models/poll.d.ts.map +1 -1
  52. package/lib/models/poll.js +1 -5
  53. package/lib/models/poll.js.map +1 -1
  54. package/lib/models/relations-container.d.ts.map +1 -1
  55. package/lib/models/relations-container.js +1 -7
  56. package/lib/models/relations-container.js.map +1 -1
  57. package/lib/models/relations.d.ts +0 -1
  58. package/lib/models/relations.d.ts.map +1 -1
  59. package/lib/models/relations.js +0 -8
  60. package/lib/models/relations.js.map +1 -1
  61. package/lib/models/room-state.d.ts +2 -13
  62. package/lib/models/room-state.d.ts.map +1 -1
  63. package/lib/models/room-state.js +12 -56
  64. package/lib/models/room-state.js.map +1 -1
  65. package/lib/models/room.d.ts +2 -20
  66. package/lib/models/room.d.ts.map +1 -1
  67. package/lib/models/room.js +121 -162
  68. package/lib/models/room.js.map +1 -1
  69. package/lib/models/thread.d.ts.map +1 -1
  70. package/lib/models/thread.js +5 -4
  71. package/lib/models/thread.js.map +1 -1
  72. package/lib/sliding-sync-sdk.d.ts +3 -4
  73. package/lib/sliding-sync-sdk.d.ts.map +1 -1
  74. package/lib/sliding-sync-sdk.js +55 -102
  75. package/lib/sliding-sync-sdk.js.map +1 -1
  76. package/lib/sliding-sync.js +9 -6
  77. package/lib/sliding-sync.js.map +1 -1
  78. package/lib/store/indexeddb.d.ts +1 -1
  79. package/lib/store/indexeddb.d.ts.map +1 -1
  80. package/lib/store/indexeddb.js.map +1 -1
  81. package/lib/sync-accumulator.d.ts +6 -4
  82. package/lib/sync-accumulator.d.ts.map +1 -1
  83. package/lib/sync-accumulator.js +23 -12
  84. package/lib/sync-accumulator.js.map +1 -1
  85. package/lib/sync.d.ts +10 -13
  86. package/lib/sync.d.ts.map +1 -1
  87. package/lib/sync.js +94 -115
  88. package/lib/sync.js.map +1 -1
  89. package/lib/testing.d.ts +0 -48
  90. package/lib/testing.d.ts.map +1 -1
  91. package/lib/testing.js +0 -105
  92. package/lib/testing.js.map +1 -1
  93. package/lib/types.d.ts +0 -1
  94. package/lib/types.d.ts.map +1 -1
  95. package/lib/types.js.map +1 -1
  96. package/package.json +10 -11
  97. package/src/@types/event.ts +2 -36
  98. package/src/@types/global.d.ts +21 -4
  99. package/src/autodiscovery.ts +1 -1
  100. package/src/base64.ts +38 -40
  101. package/src/browser-index.ts +0 -11
  102. package/src/client.ts +68 -3087
  103. package/src/digest.ts +3 -3
  104. package/src/embedded.ts +38 -134
  105. package/src/event-mapper.ts +0 -4
  106. package/src/matrix.ts +0 -41
  107. package/src/models/MSC3089Branch.ts +0 -3
  108. package/src/models/event-timeline-set.ts +17 -38
  109. package/src/models/event-timeline.ts +10 -5
  110. package/src/models/event.ts +8 -295
  111. package/src/models/poll.ts +0 -6
  112. package/src/models/relations-container.ts +1 -8
  113. package/src/models/relations.ts +0 -8
  114. package/src/models/room-state.ts +4 -37
  115. package/src/models/room.ts +18 -68
  116. package/src/models/thread.ts +4 -3
  117. package/src/sliding-sync-sdk.ts +10 -83
  118. package/src/sliding-sync.ts +6 -6
  119. package/src/store/indexeddb.ts +1 -1
  120. package/src/sync-accumulator.ts +33 -16
  121. package/src/sync.ts +112 -143
  122. package/src/testing.ts +0 -108
  123. package/src/types.ts +0 -1
  124. package/CHANGELOG.md +0 -5910
  125. package/lib/@types/AESEncryptedSecretStoragePayload.d.ts +0 -14
  126. package/lib/@types/AESEncryptedSecretStoragePayload.d.ts.map +0 -1
  127. package/lib/@types/AESEncryptedSecretStoragePayload.js +0 -1
  128. package/lib/@types/AESEncryptedSecretStoragePayload.js.map +0 -1
  129. package/lib/@types/crypto.d.ts +0 -47
  130. package/lib/@types/crypto.d.ts.map +0 -1
  131. package/lib/@types/crypto.js +0 -1
  132. package/lib/@types/crypto.js.map +0 -1
  133. package/lib/@types/matrix-sdk-crypto-wasm.d.js +0 -1
  134. package/lib/@types/matrix-sdk-crypto-wasm.d.js.map +0 -1
  135. package/lib/common-crypto/CryptoBackend.d.ts +0 -240
  136. package/lib/common-crypto/CryptoBackend.d.ts.map +0 -1
  137. package/lib/common-crypto/CryptoBackend.js +0 -73
  138. package/lib/common-crypto/CryptoBackend.js.map +0 -1
  139. package/lib/common-crypto/key-passphrase.d.ts +0 -14
  140. package/lib/common-crypto/key-passphrase.d.ts.map +0 -1
  141. package/lib/common-crypto/key-passphrase.js +0 -33
  142. package/lib/common-crypto/key-passphrase.js.map +0 -1
  143. package/lib/crypto/CrossSigning.d.ts +0 -184
  144. package/lib/crypto/CrossSigning.d.ts.map +0 -1
  145. package/lib/crypto/CrossSigning.js +0 -718
  146. package/lib/crypto/CrossSigning.js.map +0 -1
  147. package/lib/crypto/DeviceList.d.ts +0 -216
  148. package/lib/crypto/DeviceList.d.ts.map +0 -1
  149. package/lib/crypto/DeviceList.js +0 -892
  150. package/lib/crypto/DeviceList.js.map +0 -1
  151. package/lib/crypto/EncryptionSetup.d.ts +0 -152
  152. package/lib/crypto/EncryptionSetup.d.ts.map +0 -1
  153. package/lib/crypto/EncryptionSetup.js +0 -356
  154. package/lib/crypto/EncryptionSetup.js.map +0 -1
  155. package/lib/crypto/OlmDevice.d.ts +0 -457
  156. package/lib/crypto/OlmDevice.d.ts.map +0 -1
  157. package/lib/crypto/OlmDevice.js +0 -1241
  158. package/lib/crypto/OlmDevice.js.map +0 -1
  159. package/lib/crypto/OutgoingRoomKeyRequestManager.d.ts +0 -109
  160. package/lib/crypto/OutgoingRoomKeyRequestManager.d.ts.map +0 -1
  161. package/lib/crypto/OutgoingRoomKeyRequestManager.js +0 -415
  162. package/lib/crypto/OutgoingRoomKeyRequestManager.js.map +0 -1
  163. package/lib/crypto/RoomList.d.ts +0 -26
  164. package/lib/crypto/RoomList.d.ts.map +0 -1
  165. package/lib/crypto/RoomList.js +0 -71
  166. package/lib/crypto/RoomList.js.map +0 -1
  167. package/lib/crypto/SecretSharing.d.ts +0 -24
  168. package/lib/crypto/SecretSharing.d.ts.map +0 -1
  169. package/lib/crypto/SecretSharing.js +0 -194
  170. package/lib/crypto/SecretSharing.js.map +0 -1
  171. package/lib/crypto/SecretStorage.d.ts +0 -55
  172. package/lib/crypto/SecretStorage.d.ts.map +0 -1
  173. package/lib/crypto/SecretStorage.js +0 -118
  174. package/lib/crypto/SecretStorage.js.map +0 -1
  175. package/lib/crypto/aes.d.ts +0 -6
  176. package/lib/crypto/aes.d.ts.map +0 -1
  177. package/lib/crypto/aes.js +0 -24
  178. package/lib/crypto/aes.js.map +0 -1
  179. package/lib/crypto/algorithms/base.d.ts +0 -156
  180. package/lib/crypto/algorithms/base.d.ts.map +0 -1
  181. package/lib/crypto/algorithms/base.js +0 -187
  182. package/lib/crypto/algorithms/base.js.map +0 -1
  183. package/lib/crypto/algorithms/index.d.ts +0 -4
  184. package/lib/crypto/algorithms/index.d.ts.map +0 -1
  185. package/lib/crypto/algorithms/index.js +0 -20
  186. package/lib/crypto/algorithms/index.js.map +0 -1
  187. package/lib/crypto/algorithms/megolm.d.ts +0 -385
  188. package/lib/crypto/algorithms/megolm.d.ts.map +0 -1
  189. package/lib/crypto/algorithms/megolm.js +0 -1822
  190. package/lib/crypto/algorithms/megolm.js.map +0 -1
  191. package/lib/crypto/algorithms/olm.d.ts +0 -5
  192. package/lib/crypto/algorithms/olm.d.ts.map +0 -1
  193. package/lib/crypto/algorithms/olm.js +0 -299
  194. package/lib/crypto/algorithms/olm.js.map +0 -1
  195. package/lib/crypto/api.d.ts +0 -32
  196. package/lib/crypto/api.d.ts.map +0 -1
  197. package/lib/crypto/api.js +0 -22
  198. package/lib/crypto/api.js.map +0 -1
  199. package/lib/crypto/backup.d.ts +0 -227
  200. package/lib/crypto/backup.d.ts.map +0 -1
  201. package/lib/crypto/backup.js +0 -824
  202. package/lib/crypto/backup.js.map +0 -1
  203. package/lib/crypto/crypto.d.ts +0 -3
  204. package/lib/crypto/crypto.d.ts.map +0 -1
  205. package/lib/crypto/crypto.js +0 -19
  206. package/lib/crypto/crypto.js.map +0 -1
  207. package/lib/crypto/dehydration.d.ts +0 -34
  208. package/lib/crypto/dehydration.d.ts.map +0 -1
  209. package/lib/crypto/dehydration.js +0 -252
  210. package/lib/crypto/dehydration.js.map +0 -1
  211. package/lib/crypto/device-converter.d.ts +0 -9
  212. package/lib/crypto/device-converter.d.ts.map +0 -1
  213. package/lib/crypto/device-converter.js +0 -42
  214. package/lib/crypto/device-converter.js.map +0 -1
  215. package/lib/crypto/deviceinfo.d.ts +0 -99
  216. package/lib/crypto/deviceinfo.d.ts.map +0 -1
  217. package/lib/crypto/deviceinfo.js +0 -148
  218. package/lib/crypto/deviceinfo.js.map +0 -1
  219. package/lib/crypto/index.d.ts +0 -1210
  220. package/lib/crypto/index.d.ts.map +0 -1
  221. package/lib/crypto/index.js +0 -4101
  222. package/lib/crypto/index.js.map +0 -1
  223. package/lib/crypto/key_passphrase.d.ts +0 -14
  224. package/lib/crypto/key_passphrase.d.ts.map +0 -1
  225. package/lib/crypto/key_passphrase.js +0 -44
  226. package/lib/crypto/key_passphrase.js.map +0 -1
  227. package/lib/crypto/keybackup.d.ts +0 -18
  228. package/lib/crypto/keybackup.d.ts.map +0 -1
  229. package/lib/crypto/keybackup.js +0 -1
  230. package/lib/crypto/keybackup.js.map +0 -1
  231. package/lib/crypto/olmlib.d.ts +0 -129
  232. package/lib/crypto/olmlib.d.ts.map +0 -1
  233. package/lib/crypto/olmlib.js +0 -492
  234. package/lib/crypto/olmlib.js.map +0 -1
  235. package/lib/crypto/recoverykey.d.ts +0 -2
  236. package/lib/crypto/recoverykey.d.ts.map +0 -1
  237. package/lib/crypto/recoverykey.js +0 -19
  238. package/lib/crypto/recoverykey.js.map +0 -1
  239. package/lib/crypto/store/base.d.ts +0 -252
  240. package/lib/crypto/store/base.d.ts.map +0 -1
  241. package/lib/crypto/store/base.js +0 -64
  242. package/lib/crypto/store/base.js.map +0 -1
  243. package/lib/crypto/store/indexeddb-crypto-store-backend.d.ts +0 -187
  244. package/lib/crypto/store/indexeddb-crypto-store-backend.d.ts.map +0 -1
  245. package/lib/crypto/store/indexeddb-crypto-store-backend.js +0 -1145
  246. package/lib/crypto/store/indexeddb-crypto-store-backend.js.map +0 -1
  247. package/lib/crypto/store/indexeddb-crypto-store.d.ts +0 -432
  248. package/lib/crypto/store/indexeddb-crypto-store.d.ts.map +0 -1
  249. package/lib/crypto/store/indexeddb-crypto-store.js +0 -728
  250. package/lib/crypto/store/indexeddb-crypto-store.js.map +0 -1
  251. package/lib/crypto/store/localStorage-crypto-store.d.ts +0 -119
  252. package/lib/crypto/store/localStorage-crypto-store.d.ts.map +0 -1
  253. package/lib/crypto/store/localStorage-crypto-store.js +0 -531
  254. package/lib/crypto/store/localStorage-crypto-store.js.map +0 -1
  255. package/lib/crypto/store/memory-crypto-store.d.ts +0 -215
  256. package/lib/crypto/store/memory-crypto-store.d.ts.map +0 -1
  257. package/lib/crypto/store/memory-crypto-store.js +0 -622
  258. package/lib/crypto/store/memory-crypto-store.js.map +0 -1
  259. package/lib/crypto/verification/Base.d.ts +0 -105
  260. package/lib/crypto/verification/Base.d.ts.map +0 -1
  261. package/lib/crypto/verification/Base.js +0 -372
  262. package/lib/crypto/verification/Base.js.map +0 -1
  263. package/lib/crypto/verification/Error.d.ts +0 -35
  264. package/lib/crypto/verification/Error.d.ts.map +0 -1
  265. package/lib/crypto/verification/Error.js +0 -86
  266. package/lib/crypto/verification/Error.js.map +0 -1
  267. package/lib/crypto/verification/IllegalMethod.d.ts +0 -15
  268. package/lib/crypto/verification/IllegalMethod.d.ts.map +0 -1
  269. package/lib/crypto/verification/IllegalMethod.js +0 -43
  270. package/lib/crypto/verification/IllegalMethod.js.map +0 -1
  271. package/lib/crypto/verification/QRCode.d.ts +0 -51
  272. package/lib/crypto/verification/QRCode.d.ts.map +0 -1
  273. package/lib/crypto/verification/QRCode.js +0 -277
  274. package/lib/crypto/verification/QRCode.js.map +0 -1
  275. package/lib/crypto/verification/SAS.d.ts +0 -27
  276. package/lib/crypto/verification/SAS.d.ts.map +0 -1
  277. package/lib/crypto/verification/SAS.js +0 -485
  278. package/lib/crypto/verification/SAS.js.map +0 -1
  279. package/lib/crypto/verification/SASDecimal.d.ts +0 -8
  280. package/lib/crypto/verification/SASDecimal.d.ts.map +0 -1
  281. package/lib/crypto/verification/SASDecimal.js +0 -34
  282. package/lib/crypto/verification/SASDecimal.js.map +0 -1
  283. package/lib/crypto/verification/request/Channel.d.ts +0 -18
  284. package/lib/crypto/verification/request/Channel.d.ts.map +0 -1
  285. package/lib/crypto/verification/request/Channel.js +0 -1
  286. package/lib/crypto/verification/request/Channel.js.map +0 -1
  287. package/lib/crypto/verification/request/InRoomChannel.d.ts +0 -113
  288. package/lib/crypto/verification/request/InRoomChannel.d.ts.map +0 -1
  289. package/lib/crypto/verification/request/InRoomChannel.js +0 -351
  290. package/lib/crypto/verification/request/InRoomChannel.js.map +0 -1
  291. package/lib/crypto/verification/request/ToDeviceChannel.d.ts +0 -105
  292. package/lib/crypto/verification/request/ToDeviceChannel.d.ts.map +0 -1
  293. package/lib/crypto/verification/request/ToDeviceChannel.js +0 -328
  294. package/lib/crypto/verification/request/ToDeviceChannel.js.map +0 -1
  295. package/lib/crypto/verification/request/VerificationRequest.d.ts +0 -227
  296. package/lib/crypto/verification/request/VerificationRequest.d.ts.map +0 -1
  297. package/lib/crypto/verification/request/VerificationRequest.js +0 -937
  298. package/lib/crypto/verification/request/VerificationRequest.js.map +0 -1
  299. package/lib/crypto-api/CryptoEvent.d.ts +0 -69
  300. package/lib/crypto-api/CryptoEvent.d.ts.map +0 -1
  301. package/lib/crypto-api/CryptoEvent.js +0 -33
  302. package/lib/crypto-api/CryptoEvent.js.map +0 -1
  303. package/lib/crypto-api/CryptoEventHandlerMap.d.ts +0 -16
  304. package/lib/crypto-api/CryptoEventHandlerMap.d.ts.map +0 -1
  305. package/lib/crypto-api/CryptoEventHandlerMap.js +0 -22
  306. package/lib/crypto-api/CryptoEventHandlerMap.js.map +0 -1
  307. package/lib/crypto-api/index.d.ts +0 -978
  308. package/lib/crypto-api/index.d.ts.map +0 -1
  309. package/lib/crypto-api/index.js +0 -304
  310. package/lib/crypto-api/index.js.map +0 -1
  311. package/lib/crypto-api/key-passphrase.d.ts +0 -11
  312. package/lib/crypto-api/key-passphrase.d.ts.map +0 -1
  313. package/lib/crypto-api/key-passphrase.js +0 -51
  314. package/lib/crypto-api/key-passphrase.js.map +0 -1
  315. package/lib/crypto-api/keybackup.d.ts +0 -88
  316. package/lib/crypto-api/keybackup.d.ts.map +0 -1
  317. package/lib/crypto-api/keybackup.js +0 -1
  318. package/lib/crypto-api/keybackup.js.map +0 -1
  319. package/lib/crypto-api/recovery-key.d.ts +0 -11
  320. package/lib/crypto-api/recovery-key.d.ts.map +0 -1
  321. package/lib/crypto-api/recovery-key.js +0 -65
  322. package/lib/crypto-api/recovery-key.js.map +0 -1
  323. package/lib/crypto-api/verification.d.ts +0 -344
  324. package/lib/crypto-api/verification.d.ts.map +0 -1
  325. package/lib/crypto-api/verification.js +0 -91
  326. package/lib/crypto-api/verification.js.map +0 -1
  327. package/lib/matrixrtc/CallMembership.d.ts +0 -66
  328. package/lib/matrixrtc/CallMembership.d.ts.map +0 -1
  329. package/lib/matrixrtc/CallMembership.js +0 -197
  330. package/lib/matrixrtc/CallMembership.js.map +0 -1
  331. package/lib/matrixrtc/LivekitFocus.d.ts +0 -16
  332. package/lib/matrixrtc/LivekitFocus.d.ts.map +0 -1
  333. package/lib/matrixrtc/LivekitFocus.js +0 -20
  334. package/lib/matrixrtc/LivekitFocus.js.map +0 -1
  335. package/lib/matrixrtc/MatrixRTCSession.d.ts +0 -295
  336. package/lib/matrixrtc/MatrixRTCSession.d.ts.map +0 -1
  337. package/lib/matrixrtc/MatrixRTCSession.js +0 -1043
  338. package/lib/matrixrtc/MatrixRTCSession.js.map +0 -1
  339. package/lib/matrixrtc/MatrixRTCSessionManager.d.ts +0 -40
  340. package/lib/matrixrtc/MatrixRTCSessionManager.d.ts.map +0 -1
  341. package/lib/matrixrtc/MatrixRTCSessionManager.js +0 -146
  342. package/lib/matrixrtc/MatrixRTCSessionManager.js.map +0 -1
  343. package/lib/matrixrtc/focus.d.ts +0 -10
  344. package/lib/matrixrtc/focus.d.ts.map +0 -1
  345. package/lib/matrixrtc/focus.js +0 -1
  346. package/lib/matrixrtc/focus.js.map +0 -1
  347. package/lib/matrixrtc/index.d.ts +0 -7
  348. package/lib/matrixrtc/index.d.ts.map +0 -1
  349. package/lib/matrixrtc/index.js +0 -21
  350. package/lib/matrixrtc/index.js.map +0 -1
  351. package/lib/matrixrtc/types.d.ts +0 -19
  352. package/lib/matrixrtc/types.d.ts.map +0 -1
  353. package/lib/matrixrtc/types.js +0 -1
  354. package/lib/matrixrtc/types.js.map +0 -1
  355. package/lib/rendezvous/MSC4108SignInWithQR.d.ts +0 -112
  356. package/lib/rendezvous/MSC4108SignInWithQR.d.ts.map +0 -1
  357. package/lib/rendezvous/MSC4108SignInWithQR.js +0 -392
  358. package/lib/rendezvous/MSC4108SignInWithQR.js.map +0 -1
  359. package/lib/rendezvous/RendezvousChannel.d.ts +0 -27
  360. package/lib/rendezvous/RendezvousChannel.d.ts.map +0 -1
  361. package/lib/rendezvous/RendezvousChannel.js +0 -1
  362. package/lib/rendezvous/RendezvousChannel.js.map +0 -1
  363. package/lib/rendezvous/RendezvousCode.d.ts +0 -9
  364. package/lib/rendezvous/RendezvousCode.d.ts.map +0 -1
  365. package/lib/rendezvous/RendezvousCode.js +0 -1
  366. package/lib/rendezvous/RendezvousCode.js.map +0 -1
  367. package/lib/rendezvous/RendezvousError.d.ts +0 -6
  368. package/lib/rendezvous/RendezvousError.d.ts.map +0 -1
  369. package/lib/rendezvous/RendezvousError.js +0 -23
  370. package/lib/rendezvous/RendezvousError.js.map +0 -1
  371. package/lib/rendezvous/RendezvousFailureReason.d.ts +0 -31
  372. package/lib/rendezvous/RendezvousFailureReason.d.ts.map +0 -1
  373. package/lib/rendezvous/RendezvousFailureReason.js +0 -38
  374. package/lib/rendezvous/RendezvousFailureReason.js.map +0 -1
  375. package/lib/rendezvous/RendezvousIntent.d.ts +0 -5
  376. package/lib/rendezvous/RendezvousIntent.d.ts.map +0 -1
  377. package/lib/rendezvous/RendezvousIntent.js +0 -22
  378. package/lib/rendezvous/RendezvousIntent.js.map +0 -1
  379. package/lib/rendezvous/RendezvousTransport.d.ts +0 -36
  380. package/lib/rendezvous/RendezvousTransport.d.ts.map +0 -1
  381. package/lib/rendezvous/RendezvousTransport.js +0 -1
  382. package/lib/rendezvous/RendezvousTransport.js.map +0 -1
  383. package/lib/rendezvous/channels/MSC4108SecureChannel.d.ts +0 -58
  384. package/lib/rendezvous/channels/MSC4108SecureChannel.d.ts.map +0 -1
  385. package/lib/rendezvous/channels/MSC4108SecureChannel.js +0 -246
  386. package/lib/rendezvous/channels/MSC4108SecureChannel.js.map +0 -1
  387. package/lib/rendezvous/channels/index.d.ts +0 -2
  388. package/lib/rendezvous/channels/index.d.ts.map +0 -1
  389. package/lib/rendezvous/channels/index.js +0 -18
  390. package/lib/rendezvous/channels/index.js.map +0 -1
  391. package/lib/rendezvous/index.d.ts +0 -10
  392. package/lib/rendezvous/index.d.ts.map +0 -1
  393. package/lib/rendezvous/index.js +0 -23
  394. package/lib/rendezvous/index.js.map +0 -1
  395. package/lib/rendezvous/transports/MSC4108RendezvousSession.d.ts +0 -61
  396. package/lib/rendezvous/transports/MSC4108RendezvousSession.d.ts.map +0 -1
  397. package/lib/rendezvous/transports/MSC4108RendezvousSession.js +0 -253
  398. package/lib/rendezvous/transports/MSC4108RendezvousSession.js.map +0 -1
  399. package/lib/rendezvous/transports/index.d.ts +0 -2
  400. package/lib/rendezvous/transports/index.d.ts.map +0 -1
  401. package/lib/rendezvous/transports/index.js +0 -18
  402. package/lib/rendezvous/transports/index.js.map +0 -1
  403. package/lib/rust-crypto/CrossSigningIdentity.d.ts +0 -33
  404. package/lib/rust-crypto/CrossSigningIdentity.d.ts.map +0 -1
  405. package/lib/rust-crypto/CrossSigningIdentity.js +0 -157
  406. package/lib/rust-crypto/CrossSigningIdentity.js.map +0 -1
  407. package/lib/rust-crypto/DehydratedDeviceManager.d.ts +0 -98
  408. package/lib/rust-crypto/DehydratedDeviceManager.d.ts.map +0 -1
  409. package/lib/rust-crypto/DehydratedDeviceManager.js +0 -285
  410. package/lib/rust-crypto/DehydratedDeviceManager.js.map +0 -1
  411. package/lib/rust-crypto/KeyClaimManager.d.ts +0 -33
  412. package/lib/rust-crypto/KeyClaimManager.d.ts.map +0 -1
  413. package/lib/rust-crypto/KeyClaimManager.js +0 -82
  414. package/lib/rust-crypto/KeyClaimManager.js.map +0 -1
  415. package/lib/rust-crypto/OutgoingRequestProcessor.d.ts +0 -43
  416. package/lib/rust-crypto/OutgoingRequestProcessor.d.ts.map +0 -1
  417. package/lib/rust-crypto/OutgoingRequestProcessor.js +0 -195
  418. package/lib/rust-crypto/OutgoingRequestProcessor.js.map +0 -1
  419. package/lib/rust-crypto/OutgoingRequestsManager.d.ts +0 -47
  420. package/lib/rust-crypto/OutgoingRequestsManager.d.ts.map +0 -1
  421. package/lib/rust-crypto/OutgoingRequestsManager.js +0 -148
  422. package/lib/rust-crypto/OutgoingRequestsManager.js.map +0 -1
  423. package/lib/rust-crypto/PerSessionKeyBackupDownloader.d.ts +0 -120
  424. package/lib/rust-crypto/PerSessionKeyBackupDownloader.d.ts.map +0 -1
  425. package/lib/rust-crypto/PerSessionKeyBackupDownloader.js +0 -467
  426. package/lib/rust-crypto/PerSessionKeyBackupDownloader.js.map +0 -1
  427. package/lib/rust-crypto/RoomEncryptor.d.ts +0 -98
  428. package/lib/rust-crypto/RoomEncryptor.d.ts.map +0 -1
  429. package/lib/rust-crypto/RoomEncryptor.js +0 -299
  430. package/lib/rust-crypto/RoomEncryptor.js.map +0 -1
  431. package/lib/rust-crypto/backup.d.ts +0 -254
  432. package/lib/rust-crypto/backup.d.ts.map +0 -1
  433. package/lib/rust-crypto/backup.js +0 -837
  434. package/lib/rust-crypto/backup.js.map +0 -1
  435. package/lib/rust-crypto/constants.d.ts +0 -3
  436. package/lib/rust-crypto/constants.d.ts.map +0 -1
  437. package/lib/rust-crypto/constants.js +0 -19
  438. package/lib/rust-crypto/constants.js.map +0 -1
  439. package/lib/rust-crypto/device-converter.d.ts +0 -28
  440. package/lib/rust-crypto/device-converter.d.ts.map +0 -1
  441. package/lib/rust-crypto/device-converter.js +0 -123
  442. package/lib/rust-crypto/device-converter.js.map +0 -1
  443. package/lib/rust-crypto/index.d.ts +0 -61
  444. package/lib/rust-crypto/index.d.ts.map +0 -1
  445. package/lib/rust-crypto/index.js +0 -152
  446. package/lib/rust-crypto/index.js.map +0 -1
  447. package/lib/rust-crypto/libolm_migration.d.ts +0 -81
  448. package/lib/rust-crypto/libolm_migration.d.ts.map +0 -1
  449. package/lib/rust-crypto/libolm_migration.js +0 -459
  450. package/lib/rust-crypto/libolm_migration.js.map +0 -1
  451. package/lib/rust-crypto/rust-crypto.d.ts +0 -556
  452. package/lib/rust-crypto/rust-crypto.d.ts.map +0 -1
  453. package/lib/rust-crypto/rust-crypto.js +0 -2016
  454. package/lib/rust-crypto/rust-crypto.js.map +0 -1
  455. package/lib/rust-crypto/secret-storage.d.ts +0 -22
  456. package/lib/rust-crypto/secret-storage.d.ts.map +0 -1
  457. package/lib/rust-crypto/secret-storage.js +0 -63
  458. package/lib/rust-crypto/secret-storage.js.map +0 -1
  459. package/lib/rust-crypto/verification.d.ts +0 -319
  460. package/lib/rust-crypto/verification.d.ts.map +0 -1
  461. package/lib/rust-crypto/verification.js +0 -816
  462. package/lib/rust-crypto/verification.js.map +0 -1
  463. package/lib/secret-storage.d.ts +0 -370
  464. package/lib/secret-storage.d.ts.map +0 -1
  465. package/lib/secret-storage.js +0 -466
  466. package/lib/secret-storage.js.map +0 -1
  467. package/lib/utils/decryptAESSecretStorageItem.d.ts +0 -12
  468. package/lib/utils/decryptAESSecretStorageItem.d.ts.map +0 -1
  469. package/lib/utils/decryptAESSecretStorageItem.js +0 -50
  470. package/lib/utils/decryptAESSecretStorageItem.js.map +0 -1
  471. package/lib/utils/encryptAESSecretStorageItem.d.ts +0 -16
  472. package/lib/utils/encryptAESSecretStorageItem.d.ts.map +0 -1
  473. package/lib/utils/encryptAESSecretStorageItem.js +0 -68
  474. package/lib/utils/encryptAESSecretStorageItem.js.map +0 -1
  475. package/lib/utils/internal/deriveKeys.d.ts +0 -10
  476. package/lib/utils/internal/deriveKeys.d.ts.map +0 -1
  477. package/lib/utils/internal/deriveKeys.js +0 -60
  478. package/lib/utils/internal/deriveKeys.js.map +0 -1
  479. package/lib/webrtc/audioContext.d.ts +0 -15
  480. package/lib/webrtc/audioContext.d.ts.map +0 -1
  481. package/lib/webrtc/audioContext.js +0 -46
  482. package/lib/webrtc/audioContext.js.map +0 -1
  483. package/lib/webrtc/call.d.ts +0 -560
  484. package/lib/webrtc/call.d.ts.map +0 -1
  485. package/lib/webrtc/call.js +0 -2541
  486. package/lib/webrtc/call.js.map +0 -1
  487. package/lib/webrtc/callEventHandler.d.ts +0 -37
  488. package/lib/webrtc/callEventHandler.d.ts.map +0 -1
  489. package/lib/webrtc/callEventHandler.js +0 -344
  490. package/lib/webrtc/callEventHandler.js.map +0 -1
  491. package/lib/webrtc/callEventTypes.d.ts +0 -73
  492. package/lib/webrtc/callEventTypes.d.ts.map +0 -1
  493. package/lib/webrtc/callEventTypes.js +0 -13
  494. package/lib/webrtc/callEventTypes.js.map +0 -1
  495. package/lib/webrtc/callFeed.d.ts +0 -128
  496. package/lib/webrtc/callFeed.d.ts.map +0 -1
  497. package/lib/webrtc/callFeed.js +0 -289
  498. package/lib/webrtc/callFeed.js.map +0 -1
  499. package/lib/webrtc/groupCall.d.ts +0 -323
  500. package/lib/webrtc/groupCall.d.ts.map +0 -1
  501. package/lib/webrtc/groupCall.js +0 -1337
  502. package/lib/webrtc/groupCall.js.map +0 -1
  503. package/lib/webrtc/groupCallEventHandler.d.ts +0 -31
  504. package/lib/webrtc/groupCallEventHandler.d.ts.map +0 -1
  505. package/lib/webrtc/groupCallEventHandler.js +0 -178
  506. package/lib/webrtc/groupCallEventHandler.js.map +0 -1
  507. package/lib/webrtc/mediaHandler.d.ts +0 -89
  508. package/lib/webrtc/mediaHandler.d.ts.map +0 -1
  509. package/lib/webrtc/mediaHandler.js +0 -437
  510. package/lib/webrtc/mediaHandler.js.map +0 -1
  511. package/lib/webrtc/stats/callFeedStatsReporter.d.ts +0 -8
  512. package/lib/webrtc/stats/callFeedStatsReporter.d.ts.map +0 -1
  513. package/lib/webrtc/stats/callFeedStatsReporter.js +0 -82
  514. package/lib/webrtc/stats/callFeedStatsReporter.js.map +0 -1
  515. package/lib/webrtc/stats/callStatsReportGatherer.d.ts +0 -25
  516. package/lib/webrtc/stats/callStatsReportGatherer.d.ts.map +0 -1
  517. package/lib/webrtc/stats/callStatsReportGatherer.js +0 -199
  518. package/lib/webrtc/stats/callStatsReportGatherer.js.map +0 -1
  519. package/lib/webrtc/stats/callStatsReportSummary.d.ts +0 -17
  520. package/lib/webrtc/stats/callStatsReportSummary.d.ts.map +0 -1
  521. package/lib/webrtc/stats/callStatsReportSummary.js +0 -1
  522. package/lib/webrtc/stats/callStatsReportSummary.js.map +0 -1
  523. package/lib/webrtc/stats/connectionStats.d.ts +0 -28
  524. package/lib/webrtc/stats/connectionStats.d.ts.map +0 -1
  525. package/lib/webrtc/stats/connectionStats.js +0 -26
  526. package/lib/webrtc/stats/connectionStats.js.map +0 -1
  527. package/lib/webrtc/stats/connectionStatsBuilder.d.ts +0 -5
  528. package/lib/webrtc/stats/connectionStatsBuilder.d.ts.map +0 -1
  529. package/lib/webrtc/stats/connectionStatsBuilder.js +0 -27
  530. package/lib/webrtc/stats/connectionStatsBuilder.js.map +0 -1
  531. package/lib/webrtc/stats/connectionStatsReportBuilder.d.ts +0 -7
  532. package/lib/webrtc/stats/connectionStatsReportBuilder.d.ts.map +0 -1
  533. package/lib/webrtc/stats/connectionStatsReportBuilder.js +0 -121
  534. package/lib/webrtc/stats/connectionStatsReportBuilder.js.map +0 -1
  535. package/lib/webrtc/stats/groupCallStats.d.ts +0 -22
  536. package/lib/webrtc/stats/groupCallStats.d.ts.map +0 -1
  537. package/lib/webrtc/stats/groupCallStats.js +0 -78
  538. package/lib/webrtc/stats/groupCallStats.js.map +0 -1
  539. package/lib/webrtc/stats/media/mediaSsrcHandler.d.ts +0 -10
  540. package/lib/webrtc/stats/media/mediaSsrcHandler.d.ts.map +0 -1
  541. package/lib/webrtc/stats/media/mediaSsrcHandler.js +0 -57
  542. package/lib/webrtc/stats/media/mediaSsrcHandler.js.map +0 -1
  543. package/lib/webrtc/stats/media/mediaTrackHandler.d.ts +0 -12
  544. package/lib/webrtc/stats/media/mediaTrackHandler.d.ts.map +0 -1
  545. package/lib/webrtc/stats/media/mediaTrackHandler.js +0 -62
  546. package/lib/webrtc/stats/media/mediaTrackHandler.js.map +0 -1
  547. package/lib/webrtc/stats/media/mediaTrackStats.d.ts +0 -86
  548. package/lib/webrtc/stats/media/mediaTrackStats.d.ts.map +0 -1
  549. package/lib/webrtc/stats/media/mediaTrackStats.js +0 -142
  550. package/lib/webrtc/stats/media/mediaTrackStats.js.map +0 -1
  551. package/lib/webrtc/stats/media/mediaTrackStatsHandler.d.ts +0 -22
  552. package/lib/webrtc/stats/media/mediaTrackStatsHandler.d.ts.map +0 -1
  553. package/lib/webrtc/stats/media/mediaTrackStatsHandler.js +0 -76
  554. package/lib/webrtc/stats/media/mediaTrackStatsHandler.js.map +0 -1
  555. package/lib/webrtc/stats/statsReport.d.ts +0 -99
  556. package/lib/webrtc/stats/statsReport.d.ts.map +0 -1
  557. package/lib/webrtc/stats/statsReport.js +0 -32
  558. package/lib/webrtc/stats/statsReport.js.map +0 -1
  559. package/lib/webrtc/stats/statsReportEmitter.d.ts +0 -15
  560. package/lib/webrtc/stats/statsReportEmitter.d.ts.map +0 -1
  561. package/lib/webrtc/stats/statsReportEmitter.js +0 -33
  562. package/lib/webrtc/stats/statsReportEmitter.js.map +0 -1
  563. package/lib/webrtc/stats/summaryStatsReportGatherer.d.ts +0 -16
  564. package/lib/webrtc/stats/summaryStatsReportGatherer.d.ts.map +0 -1
  565. package/lib/webrtc/stats/summaryStatsReportGatherer.js +0 -116
  566. package/lib/webrtc/stats/summaryStatsReportGatherer.js.map +0 -1
  567. package/lib/webrtc/stats/trackStatsBuilder.d.ts +0 -19
  568. package/lib/webrtc/stats/trackStatsBuilder.d.ts.map +0 -1
  569. package/lib/webrtc/stats/trackStatsBuilder.js +0 -168
  570. package/lib/webrtc/stats/trackStatsBuilder.js.map +0 -1
  571. package/lib/webrtc/stats/transportStats.d.ts +0 -11
  572. package/lib/webrtc/stats/transportStats.d.ts.map +0 -1
  573. package/lib/webrtc/stats/transportStats.js +0 -1
  574. package/lib/webrtc/stats/transportStats.js.map +0 -1
  575. package/lib/webrtc/stats/transportStatsBuilder.d.ts +0 -5
  576. package/lib/webrtc/stats/transportStatsBuilder.d.ts.map +0 -1
  577. package/lib/webrtc/stats/transportStatsBuilder.js +0 -34
  578. package/lib/webrtc/stats/transportStatsBuilder.js.map +0 -1
  579. package/lib/webrtc/stats/valueFormatter.d.ts +0 -4
  580. package/lib/webrtc/stats/valueFormatter.d.ts.map +0 -1
  581. package/lib/webrtc/stats/valueFormatter.js +0 -25
  582. package/lib/webrtc/stats/valueFormatter.js.map +0 -1
  583. package/src/@types/AESEncryptedSecretStoragePayload.ts +0 -29
  584. package/src/@types/crypto.ts +0 -73
  585. package/src/@types/matrix-sdk-crypto-wasm.d.ts +0 -44
  586. package/src/common-crypto/CryptoBackend.ts +0 -302
  587. package/src/common-crypto/README.md +0 -4
  588. package/src/common-crypto/key-passphrase.ts +0 -43
  589. package/src/crypto/CrossSigning.ts +0 -773
  590. package/src/crypto/DeviceList.ts +0 -989
  591. package/src/crypto/EncryptionSetup.ts +0 -351
  592. package/src/crypto/OlmDevice.ts +0 -1500
  593. package/src/crypto/OutgoingRoomKeyRequestManager.ts +0 -485
  594. package/src/crypto/RoomList.ts +0 -70
  595. package/src/crypto/SecretSharing.ts +0 -240
  596. package/src/crypto/SecretStorage.ts +0 -136
  597. package/src/crypto/aes.ts +0 -23
  598. package/src/crypto/algorithms/base.ts +0 -236
  599. package/src/crypto/algorithms/index.ts +0 -20
  600. package/src/crypto/algorithms/megolm.ts +0 -2216
  601. package/src/crypto/algorithms/olm.ts +0 -381
  602. package/src/crypto/api.ts +0 -70
  603. package/src/crypto/backup.ts +0 -922
  604. package/src/crypto/crypto.ts +0 -18
  605. package/src/crypto/dehydration.ts +0 -272
  606. package/src/crypto/device-converter.ts +0 -45
  607. package/src/crypto/deviceinfo.ts +0 -158
  608. package/src/crypto/index.ts +0 -4418
  609. package/src/crypto/key_passphrase.ts +0 -42
  610. package/src/crypto/keybackup.ts +0 -47
  611. package/src/crypto/olmlib.ts +0 -539
  612. package/src/crypto/recoverykey.ts +0 -18
  613. package/src/crypto/store/base.ts +0 -348
  614. package/src/crypto/store/indexeddb-crypto-store-backend.ts +0 -1250
  615. package/src/crypto/store/indexeddb-crypto-store.ts +0 -845
  616. package/src/crypto/store/localStorage-crypto-store.ts +0 -579
  617. package/src/crypto/store/memory-crypto-store.ts +0 -680
  618. package/src/crypto/verification/Base.ts +0 -409
  619. package/src/crypto/verification/Error.ts +0 -76
  620. package/src/crypto/verification/IllegalMethod.ts +0 -50
  621. package/src/crypto/verification/QRCode.ts +0 -310
  622. package/src/crypto/verification/SAS.ts +0 -494
  623. package/src/crypto/verification/SASDecimal.ts +0 -37
  624. package/src/crypto/verification/request/Channel.ts +0 -34
  625. package/src/crypto/verification/request/InRoomChannel.ts +0 -371
  626. package/src/crypto/verification/request/ToDeviceChannel.ts +0 -354
  627. package/src/crypto/verification/request/VerificationRequest.ts +0 -976
  628. package/src/crypto-api/CryptoEvent.ts +0 -93
  629. package/src/crypto-api/CryptoEventHandlerMap.ts +0 -32
  630. package/src/crypto-api/index.ts +0 -1175
  631. package/src/crypto-api/key-passphrase.ts +0 -58
  632. package/src/crypto-api/keybackup.ts +0 -115
  633. package/src/crypto-api/recovery-key.ts +0 -69
  634. package/src/crypto-api/verification.ts +0 -408
  635. package/src/matrixrtc/CallMembership.ts +0 -247
  636. package/src/matrixrtc/LivekitFocus.ts +0 -39
  637. package/src/matrixrtc/MatrixRTCSession.ts +0 -1319
  638. package/src/matrixrtc/MatrixRTCSessionManager.ts +0 -166
  639. package/src/matrixrtc/focus.ts +0 -25
  640. package/src/matrixrtc/index.ts +0 -22
  641. package/src/matrixrtc/types.ts +0 -36
  642. package/src/rendezvous/MSC4108SignInWithQR.ts +0 -444
  643. package/src/rendezvous/RendezvousChannel.ts +0 -48
  644. package/src/rendezvous/RendezvousCode.ts +0 -25
  645. package/src/rendezvous/RendezvousError.ts +0 -26
  646. package/src/rendezvous/RendezvousFailureReason.ts +0 -49
  647. package/src/rendezvous/RendezvousIntent.ts +0 -20
  648. package/src/rendezvous/RendezvousTransport.ts +0 -58
  649. package/src/rendezvous/channels/MSC4108SecureChannel.ts +0 -270
  650. package/src/rendezvous/channels/index.ts +0 -17
  651. package/src/rendezvous/index.ts +0 -25
  652. package/src/rendezvous/transports/MSC4108RendezvousSession.ts +0 -270
  653. package/src/rendezvous/transports/index.ts +0 -17
  654. package/src/rust-crypto/CrossSigningIdentity.ts +0 -183
  655. package/src/rust-crypto/DehydratedDeviceManager.ts +0 -306
  656. package/src/rust-crypto/KeyClaimManager.ts +0 -86
  657. package/src/rust-crypto/OutgoingRequestProcessor.ts +0 -236
  658. package/src/rust-crypto/OutgoingRequestsManager.ts +0 -143
  659. package/src/rust-crypto/PerSessionKeyBackupDownloader.ts +0 -501
  660. package/src/rust-crypto/RoomEncryptor.ts +0 -352
  661. package/src/rust-crypto/backup.ts +0 -881
  662. package/src/rust-crypto/constants.ts +0 -18
  663. package/src/rust-crypto/device-converter.ts +0 -128
  664. package/src/rust-crypto/index.ts +0 -237
  665. package/src/rust-crypto/libolm_migration.ts +0 -530
  666. package/src/rust-crypto/rust-crypto.ts +0 -2205
  667. package/src/rust-crypto/secret-storage.ts +0 -60
  668. package/src/rust-crypto/verification.ts +0 -830
  669. package/src/secret-storage.ts +0 -693
  670. package/src/utils/decryptAESSecretStorageItem.ts +0 -54
  671. package/src/utils/encryptAESSecretStorageItem.ts +0 -73
  672. package/src/utils/internal/deriveKeys.ts +0 -63
  673. package/src/webrtc/audioContext.ts +0 -44
  674. package/src/webrtc/call.ts +0 -3074
  675. package/src/webrtc/callEventHandler.ts +0 -425
  676. package/src/webrtc/callEventTypes.ts +0 -93
  677. package/src/webrtc/callFeed.ts +0 -364
  678. package/src/webrtc/groupCall.ts +0 -1735
  679. package/src/webrtc/groupCallEventHandler.ts +0 -234
  680. package/src/webrtc/mediaHandler.ts +0 -484
  681. package/src/webrtc/stats/callFeedStatsReporter.ts +0 -94
  682. package/src/webrtc/stats/callStatsReportGatherer.ts +0 -219
  683. package/src/webrtc/stats/callStatsReportSummary.ts +0 -30
  684. package/src/webrtc/stats/connectionStats.ts +0 -47
  685. package/src/webrtc/stats/connectionStatsBuilder.ts +0 -28
  686. package/src/webrtc/stats/connectionStatsReportBuilder.ts +0 -140
  687. package/src/webrtc/stats/groupCallStats.ts +0 -93
  688. package/src/webrtc/stats/media/mediaSsrcHandler.ts +0 -57
  689. package/src/webrtc/stats/media/mediaTrackHandler.ts +0 -76
  690. package/src/webrtc/stats/media/mediaTrackStats.ts +0 -176
  691. package/src/webrtc/stats/media/mediaTrackStatsHandler.ts +0 -90
  692. package/src/webrtc/stats/statsReport.ts +0 -133
  693. package/src/webrtc/stats/statsReportEmitter.ts +0 -49
  694. package/src/webrtc/stats/summaryStatsReportGatherer.ts +0 -148
  695. package/src/webrtc/stats/trackStatsBuilder.ts +0 -207
  696. package/src/webrtc/stats/transportStats.ts +0 -26
  697. package/src/webrtc/stats/transportStatsBuilder.ts +0 -48
  698. package/src/webrtc/stats/valueFormatter.ts +0 -27
@@ -1 +0,0 @@
1
- {"version":3,"file":"groupCall.js","names":["TypedEventEmitter","CallFeed","SPEAKING_THRESHOLD","CallErrorCode","CallEvent","CallState","genCallID","setTracksEnabled","createNewMatrixCall","CallError","RoomStateEvent","logger","ReEmitter","SDPStreamMetadataPurpose","EventType","CallEventHandlerEvent","GroupCallEventHandlerEvent","mapsEqual","GroupCallStats","StatsReport","SummaryStatsReportGatherer","CallFeedStatsReporter","KnownMembership","GroupCallIntent","GroupCallType","GroupCallTerminationReason","GroupCallEvent","GroupCallStatsReportEvent","GroupCallErrorCode","GroupCallError","Error","constructor","code","msg","err","_defineProperty","GroupCallUnknownDeviceError","userId","UnknownDevice","OtherUserSpeakingError","GroupCallState","DEVICE_TIMEOUT","getCallUserId","call","_call$getOpponentMemb","getOpponentMember","invitee","GroupCall","client","room","type","isPtt","intent","groupCallId","dataChannelsEnabled","dataChannelOptions","isCallWithoutVideoAndAudio","_room$currentState$ge","_room$currentState$ge2","useLivekit","arguments","length","undefined","livekitServiceURL","Map","report","emit","ConnectionStats","ByteSentStats","extendSummaryReport","participants","SummaryStats","localCallFeed","expandCallFeedReport","callFeeds","forEachCall","callId","getFeeds","forEach","f","push","CallFeedStats","LocalCallFeedUninitialized","newCall","_newCall$getOpponentM","_this$calls$get","roomId","state","Ringing","warn","concat","log","reject","opponentUserId","info","deviceMap","calls","get","prevCall","getOpponentDeviceId","hangup","Replaced","set","initCall","feeds","getLocalFeeds","map","feed","clone","callExpected","stream","getAudioTracks","getVideoTracks","answerWithCallFeeds","CallsChanged","needsRetry","participantMap","callMap","retriesMap","retryCallCounts","deviceId","participant","_retriesMap$get","_retriesMap","retries","getOpponentSessionId","sessionId","wantsOutgoingCall","placeOutgoingCalls","opponentMemberId","opponentDeviceId","currentUserMediaFeed","getUserMediaFeed","remoteUsermediaFeed","remoteFeedChanged","currentCallForUserDevice","addUserMediaFeed","replaceUserMediaFeed","removeUserMediaFeed","currentScreenshareFeed","getScreenshareFeed","remoteScreensharingFeed","remoteScreenshareFeedChanged","addScreenshareFeed","replaceScreenshareFeed","removeScreenshareFeed","_oldState","_call$getOpponentMemb2","Ended","audioMuted","isAudioMuted","localUsermediaStream","isMicrophoneMuted","setMicrophoneMuted","videoMuted","isVideoMuted","isLocalVideoMuted","setLocalVideoMuted","Connected","delete","size","_call$getOpponentMemb3","_call$getOpponentMemb4","hangupReason","getMember","disposeCall","topAvg","nextActiveSpeaker","callFeed","userMediaFeeds","isLocal","total","speakingVolumeSamples","reduce","acc","volume","Math","max","avg","activeSpeaker","ActiveSpeakerChanged","updateParticipants","expected","Entered","newState","oldState","updateMemberState","catch","e","error","reEmitter","_livekitServiceURL","creationTs","currentState","getStateEvents","GroupCallPrefix","getTs","on","Update","onRoomState","ParticipantsChanged","onParticipantsChanged","GroupCallStateChanged","onStateChanged","LocalScreenshareStateChanged","onLocalFeedsChanged","allowCallWithoutVideoAndAudio","create","_this","_asyncToGenerator","Date","now","groupCallEventHandler","groupCalls","Outgoing","sendCallStateEvent","_this2","groupCallState","sendStateEvent","updateLivekitServiceURL","newURL","_state","value","prevValue","_participants","participantStateEqual","x","y","screensharing","deviceMapsEqual","_creationTs","enteredViaAnotherSession","_enteredViaAnotherSession","values","localScreenshareFeed","hasLocalParticipant","_this$participants$ge","_this$participants$ge2","getUserId","has","getDeviceId","_this$participants$ge3","member","initLocalCallFeed","_this3","InitializingLocalCallFeed","initCallFeedPromise","initLocalCallFeedInternal","_this4","getMediaHandler","getUserMediaStream","Video","MediaStream","stopUserMediaStream","purpose","Usermedia","initWithAudioMuted","initWithVideoMuted","LocalCallFeedInitialized","updateLocalUsermediaStream","_this5","oldStream","setNewStream","micShouldBeMuted","vidShouldBeMuted","id","enter","_this6","Incoming","onIncomingCall","callEventHandler","retryCallLoopInterval","setInterval","onRetryCallLoop","retryCallInterval","onActiveSpeakerLoop","activeSpeakerLoopInterval","activeSpeakerInterval","dispose","_this$stats","stopScreensharingStream","localDesktopCapturerSourceId","stopAllStreams","transmitTimer","clearTimeout","clearInterval","participantsExpirationTimer","UserHangup","clear","removeListener","stats","stop","leave","terminate","_arguments","_this7","emitStateEvent","off","existingStateEvent","_objectSpread","getContent","CallEnded","muted","_this8","hasAudioDevice","sendUpdatesBefore","setTimeout","pttMaxTransmitTime","_call$localUsermediaF","localUsermediaFeed","setAudioVideoMuted","sendUpdates","_ref","updates","sendMetadataUpdate","Promise","all","apply","hasPermission","checkAudioPermissionIfNecessary","LocalMuteStateChanged","_this9","hasAudioTrack","getTracks","_unused","_this10","hasVideoDevice","_unused2","setScreensharingEnabled","enabled","_arguments2","_this11","opts","isScreensharing","getScreensharingStream","_loop","track","onTrackEnded","removeEventListener","addEventListener","desktopCapturerSourceId","Screenshare","pushLocalFeed","throwOnFail","NoUserMedia","localScreensharingFeed","removeLocalFeed","localUserId","localDeviceId","_this12","callsChanged","_loop2","_userId2","_this12$calls$get","_loop3","debug","NewSession","opponentSessionId","placeCallWithCallFeeds","then","createDataChannel","PlaceCallFailed","SignallingFailed","getMemberStateEvents","GroupCallMemberPrefix","onCallFeedsChanged","onCallStateChanged","onCallHangup","onCallReplaced","callHandlers","FeedsChanged","State","Hangup","reEmit","Object","initStats","getGroupCallStats","usermediaFeed","screenshareFeed","find","measureVolumeActivity","UserMediaFeedsChanged","existingFeed","replacementFeed","feedIndex","findIndex","splice","screenshareFeeds","ScreenshareFeedsChanged","localMember","entered","nextExpiration","Infinity","getStateKey","content","Array","isArray","devices","validDevices","filter","d","device_id","session_id","expires_ts","membership","Join","some","getSessionId","updateDevices","fn","_arguments3","_this13","_event$getContent","keepAlive","event","otherCalls","c","newDevices","newCalls","newContent","addDeviceToMemberState","_this14","_this15","resendMemberStateTimer","cleanMemberState","_this16","myDevices","getDevices","device","last_seen_ts","userID","statsCollectIntervalTime","reports","CONNECTION_STATS","onConnectionStats","BYTE_SENT_STATS","onByteSentStats","SUMMARY_STATS","onSummaryStats","CALL_FEED_REPORT","onCallFeedReport","setGroupCallStatsInterval","interval","start"],"sources":["../../src/webrtc/groupCall.ts"],"sourcesContent":["import { TypedEventEmitter } from \"../models/typed-event-emitter.ts\";\nimport { CallFeed, SPEAKING_THRESHOLD } from \"./callFeed.ts\";\nimport { MatrixClient, IMyDevice } from \"../client.ts\";\nimport {\n CallErrorCode,\n CallEvent,\n CallEventHandlerMap,\n CallState,\n genCallID,\n MatrixCall,\n setTracksEnabled,\n createNewMatrixCall,\n CallError,\n} from \"./call.ts\";\nimport { RoomMember } from \"../models/room-member.ts\";\nimport { Room } from \"../models/room.ts\";\nimport { RoomStateEvent } from \"../models/room-state.ts\";\nimport { logger } from \"../logger.ts\";\nimport { ReEmitter } from \"../ReEmitter.ts\";\nimport { SDPStreamMetadataPurpose } from \"./callEventTypes.ts\";\nimport { MatrixEvent } from \"../models/event.ts\";\nimport { EventType } from \"../@types/event.ts\";\nimport { CallEventHandlerEvent } from \"./callEventHandler.ts\";\nimport { GroupCallEventHandlerEvent } from \"./groupCallEventHandler.ts\";\nimport { IScreensharingOpts } from \"./mediaHandler.ts\";\nimport { mapsEqual } from \"../utils.ts\";\nimport { GroupCallStats } from \"./stats/groupCallStats.ts\";\nimport {\n ByteSentStatsReport,\n CallFeedReport,\n ConnectionStatsReport,\n StatsReport,\n SummaryStatsReport,\n} from \"./stats/statsReport.ts\";\nimport { SummaryStatsReportGatherer } from \"./stats/summaryStatsReportGatherer.ts\";\nimport { CallFeedStatsReporter } from \"./stats/callFeedStatsReporter.ts\";\nimport { KnownMembership } from \"../@types/membership.ts\";\nimport { CallMembershipData } from \"../matrixrtc/CallMembership.ts\";\n\nexport enum GroupCallIntent {\n Ring = \"m.ring\",\n Prompt = \"m.prompt\",\n Room = \"m.room\",\n}\n\nexport enum GroupCallType {\n Video = \"m.video\",\n Voice = \"m.voice\",\n}\n\nexport enum GroupCallTerminationReason {\n CallEnded = \"call_ended\",\n}\n\nexport type CallsByUserAndDevice = Map<string, Map<string, MatrixCall>>;\n\n/**\n * Because event names are just strings, they do need\n * to be unique over all event types of event emitter.\n * Some objects could emit more then one set of events.\n */\nexport enum GroupCallEvent {\n GroupCallStateChanged = \"group_call_state_changed\",\n ActiveSpeakerChanged = \"active_speaker_changed\",\n CallsChanged = \"calls_changed\",\n UserMediaFeedsChanged = \"user_media_feeds_changed\",\n ScreenshareFeedsChanged = \"screenshare_feeds_changed\",\n LocalScreenshareStateChanged = \"local_screenshare_state_changed\",\n LocalMuteStateChanged = \"local_mute_state_changed\",\n ParticipantsChanged = \"participants_changed\",\n Error = \"group_call_error\",\n}\n\nexport type GroupCallEventHandlerMap = {\n [GroupCallEvent.GroupCallStateChanged]: (newState: GroupCallState, oldState: GroupCallState) => void;\n [GroupCallEvent.ActiveSpeakerChanged]: (activeSpeaker: CallFeed | undefined) => void;\n [GroupCallEvent.CallsChanged]: (calls: CallsByUserAndDevice) => void;\n [GroupCallEvent.UserMediaFeedsChanged]: (feeds: CallFeed[]) => void;\n [GroupCallEvent.ScreenshareFeedsChanged]: (feeds: CallFeed[]) => void;\n [GroupCallEvent.LocalScreenshareStateChanged]: (\n isScreensharing: boolean,\n feed?: CallFeed,\n sourceId?: string,\n ) => void;\n [GroupCallEvent.LocalMuteStateChanged]: (audioMuted: boolean, videoMuted: boolean) => void;\n [GroupCallEvent.ParticipantsChanged]: (participants: Map<RoomMember, Map<string, ParticipantState>>) => void;\n /**\n * Fires whenever an error occurs when call.js encounters an issue with setting up the call.\n * <p>\n * The error given will have a code equal to either `MatrixCall.ERR_LOCAL_OFFER_FAILED` or\n * `MatrixCall.ERR_NO_USER_MEDIA`. `ERR_LOCAL_OFFER_FAILED` is emitted when the local client\n * fails to create an offer. `ERR_NO_USER_MEDIA` is emitted when the user has denied access\n * to their audio/video hardware.\n * @param error - The error raised by MatrixCall.\n * @example\n * ```\n * matrixCall.on(\"error\", function(err){\n * console.error(err.code, err);\n * });\n * ```\n */\n [GroupCallEvent.Error]: (error: GroupCallError) => void;\n};\n\nexport enum GroupCallStatsReportEvent {\n ConnectionStats = \"GroupCall.connection_stats\",\n ByteSentStats = \"GroupCall.byte_sent_stats\",\n SummaryStats = \"GroupCall.summary_stats\",\n CallFeedStats = \"GroupCall.call_feed_stats\",\n}\n\n/**\n * The final report-events that get consumed by client.\n */\nexport type GroupCallStatsReportEventHandlerMap = {\n [GroupCallStatsReportEvent.ConnectionStats]: (report: GroupCallStatsReport<ConnectionStatsReport>) => void;\n [GroupCallStatsReportEvent.ByteSentStats]: (report: GroupCallStatsReport<ByteSentStatsReport>) => void;\n [GroupCallStatsReportEvent.SummaryStats]: (report: GroupCallStatsReport<SummaryStatsReport>) => void;\n [GroupCallStatsReportEvent.CallFeedStats]: (report: GroupCallStatsReport<CallFeedReport>) => void;\n};\n\nexport enum GroupCallErrorCode {\n NoUserMedia = \"no_user_media\",\n UnknownDevice = \"unknown_device\",\n PlaceCallFailed = \"place_call_failed\",\n}\n\nexport interface GroupCallStatsReport<\n T extends ConnectionStatsReport | ByteSentStatsReport | SummaryStatsReport | CallFeedReport,\n> {\n report: T;\n}\n\nexport class GroupCallError extends Error {\n public code: string;\n\n public constructor(code: GroupCallErrorCode, msg: string, err?: Error) {\n // Still don't think there's any way to have proper nested errors\n if (err) {\n super(msg + \": \" + err);\n } else {\n super(msg);\n }\n\n this.code = code;\n }\n}\n\nexport class GroupCallUnknownDeviceError extends GroupCallError {\n public constructor(public userId: string) {\n super(GroupCallErrorCode.UnknownDevice, \"No device found for \" + userId);\n }\n}\n\nexport class OtherUserSpeakingError extends Error {\n public constructor() {\n super(\"Cannot unmute: another user is speaking\");\n }\n}\n\nexport interface IGroupCallDataChannelOptions {\n ordered: boolean;\n maxPacketLifeTime: number;\n maxRetransmits: number;\n protocol: string;\n}\n\nexport interface IGroupCallRoomState {\n \"m.intent\": GroupCallIntent;\n \"m.type\": GroupCallType;\n \"m.terminated\"?: GroupCallTerminationReason;\n \"io.element.ptt\"?: boolean;\n // TODO: Specify data-channels\n \"dataChannelsEnabled\"?: boolean;\n \"dataChannelOptions\"?: IGroupCallDataChannelOptions;\n\n \"io.element.livekit_service_url\"?: string;\n}\n\nexport interface IGroupCallRoomMemberFeed {\n purpose: SDPStreamMetadataPurpose;\n}\n\nexport interface IGroupCallRoomMemberDevice {\n device_id: string;\n session_id: string;\n expires_ts: number;\n feeds: IGroupCallRoomMemberFeed[];\n}\n\nexport interface IGroupCallRoomMemberCallState {\n \"m.call_id\": string;\n \"m.foci\"?: string[];\n \"m.devices\": IGroupCallRoomMemberDevice[];\n}\n\nexport interface IGroupCallRoomMemberState {\n \"m.calls\": IGroupCallRoomMemberCallState[];\n}\n\n// XXX: this hasn't made it into the MSC yet\nexport interface ExperimentalGroupCallRoomMemberState {\n memberships: CallMembershipData[];\n}\n\nexport enum GroupCallState {\n LocalCallFeedUninitialized = \"local_call_feed_uninitialized\",\n InitializingLocalCallFeed = \"initializing_local_call_feed\",\n LocalCallFeedInitialized = \"local_call_feed_initialized\",\n Entered = \"entered\",\n Ended = \"ended\",\n}\n\nexport interface ParticipantState {\n sessionId: string;\n screensharing: boolean;\n}\n\ninterface ICallHandlers {\n onCallFeedsChanged: (feeds: CallFeed[]) => void;\n onCallStateChanged: (state: CallState, oldState: CallState | undefined) => void;\n onCallHangup: (call: MatrixCall) => void;\n onCallReplaced: (newCall: MatrixCall) => void;\n}\n\nconst DEVICE_TIMEOUT = 1000 * 60 * 60; // 1 hour\n\nfunction getCallUserId(call: MatrixCall): string | null {\n return call.getOpponentMember()?.userId || call.invitee || null;\n}\n\nexport class GroupCall extends TypedEventEmitter<\n GroupCallEvent | CallEvent | GroupCallStatsReportEvent,\n GroupCallEventHandlerMap & CallEventHandlerMap & GroupCallStatsReportEventHandlerMap\n> {\n // Config\n public activeSpeakerInterval = 1000;\n public retryCallInterval = 5000;\n public participantTimeout = 1000 * 15;\n public pttMaxTransmitTime = 1000 * 20;\n\n public activeSpeaker?: CallFeed;\n public localCallFeed?: CallFeed;\n public localScreenshareFeed?: CallFeed;\n public localDesktopCapturerSourceId?: string;\n public readonly userMediaFeeds: CallFeed[] = [];\n public readonly screenshareFeeds: CallFeed[] = [];\n public groupCallId: string;\n public readonly allowCallWithoutVideoAndAudio: boolean;\n\n private readonly calls = new Map<string, Map<string, MatrixCall>>(); // user_id -> device_id -> MatrixCall\n private callHandlers = new Map<string, Map<string, ICallHandlers>>(); // user_id -> device_id -> ICallHandlers\n private activeSpeakerLoopInterval?: ReturnType<typeof setTimeout>;\n private retryCallLoopInterval?: ReturnType<typeof setTimeout>;\n private retryCallCounts: Map<string, Map<string, number>> = new Map(); // user_id -> device_id -> count\n private reEmitter: ReEmitter;\n private transmitTimer: ReturnType<typeof setTimeout> | null = null;\n private participantsExpirationTimer: ReturnType<typeof setTimeout> | null = null;\n private resendMemberStateTimer: ReturnType<typeof setInterval> | null = null;\n private initWithAudioMuted = false;\n private initWithVideoMuted = false;\n private initCallFeedPromise?: Promise<void>;\n private _livekitServiceURL?: string;\n\n private stats: GroupCallStats | undefined;\n /**\n * Configure default webrtc stats collection interval in ms\n * Disable collecting webrtc stats by setting interval to 0\n */\n private statsCollectIntervalTime = 0;\n\n public constructor(\n private client: MatrixClient,\n public room: Room,\n public type: GroupCallType,\n public isPtt: boolean,\n public intent: GroupCallIntent,\n groupCallId?: string,\n private dataChannelsEnabled?: boolean,\n private dataChannelOptions?: IGroupCallDataChannelOptions,\n isCallWithoutVideoAndAudio?: boolean,\n // this tells the js-sdk not to actually establish any calls to exchange media and just to\n // create the group call signaling events, with the intention that the actual media will be\n // handled using livekit. The js-sdk doesn't contain any code to do the actual livekit call though.\n private useLivekit = false,\n livekitServiceURL?: string,\n ) {\n super();\n this.reEmitter = new ReEmitter(this);\n this.groupCallId = groupCallId ?? genCallID();\n this._livekitServiceURL = livekitServiceURL;\n this.creationTs =\n room.currentState.getStateEvents(EventType.GroupCallPrefix, this.groupCallId)?.getTs() ?? null;\n this.updateParticipants();\n\n room.on(RoomStateEvent.Update, this.onRoomState);\n this.on(GroupCallEvent.ParticipantsChanged, this.onParticipantsChanged);\n this.on(GroupCallEvent.GroupCallStateChanged, this.onStateChanged);\n this.on(GroupCallEvent.LocalScreenshareStateChanged, this.onLocalFeedsChanged);\n this.allowCallWithoutVideoAndAudio = !!isCallWithoutVideoAndAudio;\n }\n\n private onConnectionStats = (report: ConnectionStatsReport): void => {\n // Final emit of the summary event, to be consumed by the client\n this.emit(GroupCallStatsReportEvent.ConnectionStats, { report });\n };\n\n private onByteSentStats = (report: ByteSentStatsReport): void => {\n // Final emit of the summary event, to be consumed by the client\n this.emit(GroupCallStatsReportEvent.ByteSentStats, { report });\n };\n\n private onSummaryStats = (report: SummaryStatsReport): void => {\n SummaryStatsReportGatherer.extendSummaryReport(report, this.participants);\n // Final emit of the summary event, to be consumed by the client\n this.emit(GroupCallStatsReportEvent.SummaryStats, { report });\n };\n\n private onCallFeedReport = (report: CallFeedReport): void => {\n if (this.localCallFeed) {\n report = CallFeedStatsReporter.expandCallFeedReport(report, [this.localCallFeed], \"from-local-feed\");\n }\n\n const callFeeds: CallFeed[] = [];\n this.forEachCall((call) => {\n if (call.callId === report.callId) {\n call.getFeeds().forEach((f) => callFeeds.push(f));\n }\n });\n\n report = CallFeedStatsReporter.expandCallFeedReport(report, callFeeds, \"from-call-feed\");\n this.emit(GroupCallStatsReportEvent.CallFeedStats, { report });\n };\n\n public async create(): Promise<GroupCall> {\n this.creationTs = Date.now();\n this.client.groupCallEventHandler!.groupCalls.set(this.room.roomId, this);\n this.client.emit(GroupCallEventHandlerEvent.Outgoing, this);\n\n await this.sendCallStateEvent();\n\n return this;\n }\n\n private async sendCallStateEvent(): Promise<void> {\n const groupCallState: IGroupCallRoomState = {\n \"m.intent\": this.intent,\n \"m.type\": this.type,\n \"io.element.ptt\": this.isPtt,\n // TODO: Specify data-channels better\n \"dataChannelsEnabled\": this.dataChannelsEnabled,\n \"dataChannelOptions\": this.dataChannelsEnabled ? this.dataChannelOptions : undefined,\n };\n if (this.livekitServiceURL) {\n groupCallState[\"io.element.livekit_service_url\"] = this.livekitServiceURL;\n }\n\n await this.client.sendStateEvent(this.room.roomId, EventType.GroupCallPrefix, groupCallState, this.groupCallId);\n }\n\n public get livekitServiceURL(): string | undefined {\n return this._livekitServiceURL;\n }\n\n public updateLivekitServiceURL(newURL: string): Promise<void> {\n this._livekitServiceURL = newURL;\n return this.sendCallStateEvent();\n }\n\n private _state = GroupCallState.LocalCallFeedUninitialized;\n\n /**\n * The group call's state.\n */\n public get state(): GroupCallState {\n return this._state;\n }\n\n private set state(value: GroupCallState) {\n const prevValue = this._state;\n if (value !== prevValue) {\n this._state = value;\n this.emit(GroupCallEvent.GroupCallStateChanged, value, prevValue);\n }\n }\n\n private _participants = new Map<RoomMember, Map<string, ParticipantState>>();\n\n /**\n * The current participants in the call, as a map from members to device IDs\n * to participant info.\n */\n public get participants(): Map<RoomMember, Map<string, ParticipantState>> {\n return this._participants;\n }\n\n private set participants(value: Map<RoomMember, Map<string, ParticipantState>>) {\n const prevValue = this._participants;\n const participantStateEqual = (x: ParticipantState, y: ParticipantState): boolean =>\n x.sessionId === y.sessionId && x.screensharing === y.screensharing;\n const deviceMapsEqual = (x: Map<string, ParticipantState>, y: Map<string, ParticipantState>): boolean =>\n mapsEqual(x, y, participantStateEqual);\n\n // Only update if the map actually changed\n if (!mapsEqual(value, prevValue, deviceMapsEqual)) {\n this._participants = value;\n this.emit(GroupCallEvent.ParticipantsChanged, value);\n }\n }\n\n private _creationTs: number | null = null;\n\n /**\n * The timestamp at which the call was created, or null if it has not yet\n * been created.\n */\n public get creationTs(): number | null {\n return this._creationTs;\n }\n\n private set creationTs(value: number | null) {\n this._creationTs = value;\n }\n\n private _enteredViaAnotherSession = false;\n\n /**\n * Whether the local device has entered this call via another session, such\n * as a widget.\n */\n public get enteredViaAnotherSession(): boolean {\n return this._enteredViaAnotherSession;\n }\n\n public set enteredViaAnotherSession(value: boolean) {\n this._enteredViaAnotherSession = value;\n this.updateParticipants();\n }\n\n /**\n * Executes the given callback on all calls in this group call.\n * @param f - The callback.\n */\n public forEachCall(f: (call: MatrixCall) => void): void {\n for (const deviceMap of this.calls.values()) {\n for (const call of deviceMap.values()) f(call);\n }\n }\n\n public getLocalFeeds(): CallFeed[] {\n const feeds: CallFeed[] = [];\n\n if (this.localCallFeed) feeds.push(this.localCallFeed);\n if (this.localScreenshareFeed) feeds.push(this.localScreenshareFeed);\n\n return feeds;\n }\n\n public hasLocalParticipant(): boolean {\n return (\n this.participants.get(this.room.getMember(this.client.getUserId()!)!)?.has(this.client.getDeviceId()!) ??\n false\n );\n }\n\n /**\n * Determines whether the given call is one that we were expecting to exist\n * given our knowledge of who is participating in the group call.\n */\n private callExpected(call: MatrixCall): boolean {\n const userId = getCallUserId(call);\n const member = userId === null ? null : this.room.getMember(userId);\n const deviceId = call.getOpponentDeviceId();\n return member !== null && deviceId !== undefined && this.participants.get(member)?.get(deviceId) !== undefined;\n }\n\n public async initLocalCallFeed(): Promise<void> {\n if (this.useLivekit) {\n logger.info(\"Livekit group call: not starting local call feed.\");\n return;\n }\n\n if (this.state !== GroupCallState.LocalCallFeedUninitialized) {\n throw new Error(`Cannot initialize local call feed in the \"${this.state}\" state.`);\n }\n this.state = GroupCallState.InitializingLocalCallFeed;\n\n // wraps the real method to serialise calls, because we don't want to try starting\n // multiple call feeds at once\n if (this.initCallFeedPromise) return this.initCallFeedPromise;\n\n try {\n this.initCallFeedPromise = this.initLocalCallFeedInternal();\n await this.initCallFeedPromise;\n } finally {\n this.initCallFeedPromise = undefined;\n }\n }\n\n private async initLocalCallFeedInternal(): Promise<void> {\n logger.log(`GroupCall ${this.groupCallId} initLocalCallFeedInternal() running`);\n\n let stream: MediaStream;\n\n try {\n stream = await this.client.getMediaHandler().getUserMediaStream(true, this.type === GroupCallType.Video);\n } catch (error) {\n // If is allowed to join a call without a media stream, then we\n // don't throw an error here. But we need an empty Local Feed to establish\n // a connection later.\n if (this.allowCallWithoutVideoAndAudio) {\n stream = new MediaStream();\n } else {\n this.state = GroupCallState.LocalCallFeedUninitialized;\n throw error;\n }\n }\n\n // The call could've been disposed while we were waiting, and could\n // also have been started back up again (hello, React 18) so if we're\n // still in this 'initializing' state, carry on, otherwise bail.\n if (this._state !== GroupCallState.InitializingLocalCallFeed) {\n this.client.getMediaHandler().stopUserMediaStream(stream);\n throw new Error(\"Group call disposed while gathering media stream\");\n }\n\n const callFeed = new CallFeed({\n client: this.client,\n roomId: this.room.roomId,\n userId: this.client.getUserId()!,\n deviceId: this.client.getDeviceId()!,\n stream,\n purpose: SDPStreamMetadataPurpose.Usermedia,\n audioMuted: this.initWithAudioMuted || stream.getAudioTracks().length === 0 || this.isPtt,\n videoMuted: this.initWithVideoMuted || stream.getVideoTracks().length === 0,\n });\n\n setTracksEnabled(stream.getAudioTracks(), !callFeed.isAudioMuted());\n setTracksEnabled(stream.getVideoTracks(), !callFeed.isVideoMuted());\n\n this.localCallFeed = callFeed;\n this.addUserMediaFeed(callFeed);\n\n this.state = GroupCallState.LocalCallFeedInitialized;\n }\n\n public async updateLocalUsermediaStream(stream: MediaStream): Promise<void> {\n if (this.localCallFeed) {\n const oldStream = this.localCallFeed.stream;\n this.localCallFeed.setNewStream(stream);\n const micShouldBeMuted = this.localCallFeed.isAudioMuted();\n const vidShouldBeMuted = this.localCallFeed.isVideoMuted();\n logger.log(\n `GroupCall ${this.groupCallId} updateLocalUsermediaStream() (oldStreamId=${oldStream.id}, newStreamId=${stream.id}, micShouldBeMuted=${micShouldBeMuted}, vidShouldBeMuted=${vidShouldBeMuted})`,\n );\n setTracksEnabled(stream.getAudioTracks(), !micShouldBeMuted);\n setTracksEnabled(stream.getVideoTracks(), !vidShouldBeMuted);\n this.client.getMediaHandler().stopUserMediaStream(oldStream);\n }\n }\n\n public async enter(): Promise<void> {\n if (this.state === GroupCallState.LocalCallFeedUninitialized) {\n await this.initLocalCallFeed();\n } else if (this.state !== GroupCallState.LocalCallFeedInitialized) {\n throw new Error(`Cannot enter call in the \"${this.state}\" state`);\n }\n\n logger.log(`GroupCall ${this.groupCallId} enter() running`);\n this.state = GroupCallState.Entered;\n\n this.client.on(CallEventHandlerEvent.Incoming, this.onIncomingCall);\n\n for (const call of this.client.callEventHandler!.calls.values()) {\n this.onIncomingCall(call);\n }\n\n if (!this.useLivekit) {\n this.retryCallLoopInterval = setInterval(this.onRetryCallLoop, this.retryCallInterval);\n\n this.activeSpeaker = undefined;\n this.onActiveSpeakerLoop();\n this.activeSpeakerLoopInterval = setInterval(this.onActiveSpeakerLoop, this.activeSpeakerInterval);\n }\n }\n\n private dispose(): void {\n if (this.localCallFeed) {\n this.removeUserMediaFeed(this.localCallFeed);\n this.localCallFeed = undefined;\n }\n\n if (this.localScreenshareFeed) {\n this.client.getMediaHandler().stopScreensharingStream(this.localScreenshareFeed.stream);\n this.removeScreenshareFeed(this.localScreenshareFeed);\n this.localScreenshareFeed = undefined;\n this.localDesktopCapturerSourceId = undefined;\n }\n\n this.client.getMediaHandler().stopAllStreams();\n\n if (this.transmitTimer !== null) {\n clearTimeout(this.transmitTimer);\n this.transmitTimer = null;\n }\n\n if (this.retryCallLoopInterval !== undefined) {\n clearInterval(this.retryCallLoopInterval);\n this.retryCallLoopInterval = undefined;\n }\n\n if (this.participantsExpirationTimer !== null) {\n clearTimeout(this.participantsExpirationTimer);\n this.participantsExpirationTimer = null;\n }\n\n if (this.state !== GroupCallState.Entered) {\n return;\n }\n\n this.forEachCall((call) => call.hangup(CallErrorCode.UserHangup, false));\n\n this.activeSpeaker = undefined;\n clearInterval(this.activeSpeakerLoopInterval);\n\n this.retryCallCounts.clear();\n clearInterval(this.retryCallLoopInterval);\n\n this.client.removeListener(CallEventHandlerEvent.Incoming, this.onIncomingCall);\n this.stats?.stop();\n }\n\n public leave(): void {\n this.dispose();\n this.state = GroupCallState.LocalCallFeedUninitialized;\n }\n\n public async terminate(emitStateEvent = true): Promise<void> {\n this.dispose();\n\n this.room.off(RoomStateEvent.Update, this.onRoomState);\n this.client.groupCallEventHandler!.groupCalls.delete(this.room.roomId);\n this.client.emit(GroupCallEventHandlerEvent.Ended, this);\n this.state = GroupCallState.Ended;\n\n if (emitStateEvent) {\n const existingStateEvent = this.room.currentState.getStateEvents(\n EventType.GroupCallPrefix,\n this.groupCallId,\n )!;\n\n await this.client.sendStateEvent(\n this.room.roomId,\n EventType.GroupCallPrefix,\n {\n ...existingStateEvent.getContent(),\n \"m.terminated\": GroupCallTerminationReason.CallEnded,\n },\n this.groupCallId,\n );\n }\n }\n\n /*\n * Local Usermedia\n */\n\n public isLocalVideoMuted(): boolean {\n if (this.localCallFeed) {\n return this.localCallFeed.isVideoMuted();\n }\n\n return true;\n }\n\n public isMicrophoneMuted(): boolean {\n if (this.localCallFeed) {\n return this.localCallFeed.isAudioMuted();\n }\n\n return true;\n }\n\n /**\n * Sets the mute state of the local participants's microphone.\n * @param muted - Whether to mute the microphone\n * @returns Whether muting/unmuting was successful\n */\n public async setMicrophoneMuted(muted: boolean): Promise<boolean> {\n // hasAudioDevice can block indefinitely if the window has lost focus,\n // and it doesn't make much sense to keep a device from being muted, so\n // we always allow muted = true changes to go through\n if (!muted && !(await this.client.getMediaHandler().hasAudioDevice())) {\n return false;\n }\n\n const sendUpdatesBefore = !muted && this.isPtt;\n\n // set a timer for the maximum transmit time on PTT calls\n if (this.isPtt) {\n // Set or clear the max transmit timer\n if (!muted && this.isMicrophoneMuted()) {\n this.transmitTimer = setTimeout(() => {\n this.setMicrophoneMuted(true);\n }, this.pttMaxTransmitTime);\n } else if (muted && !this.isMicrophoneMuted()) {\n if (this.transmitTimer !== null) clearTimeout(this.transmitTimer);\n this.transmitTimer = null;\n }\n }\n\n this.forEachCall((call) => call.localUsermediaFeed?.setAudioVideoMuted(muted, null));\n\n const sendUpdates = async (): Promise<void> => {\n const updates: Promise<void>[] = [];\n this.forEachCall((call) => updates.push(call.sendMetadataUpdate()));\n\n await Promise.all(updates).catch((e) =>\n logger.info(\n `GroupCall ${this.groupCallId} setMicrophoneMuted() failed to send some metadata updates`,\n e,\n ),\n );\n };\n\n if (sendUpdatesBefore) await sendUpdates();\n\n if (this.localCallFeed) {\n logger.log(\n `GroupCall ${this.groupCallId} setMicrophoneMuted() (streamId=${this.localCallFeed.stream.id}, muted=${muted})`,\n );\n\n const hasPermission = await this.checkAudioPermissionIfNecessary(muted);\n\n if (!hasPermission) {\n return false;\n }\n\n this.localCallFeed.setAudioVideoMuted(muted, null);\n // I don't believe its actually necessary to enable these tracks: they\n // are the one on the GroupCall's own CallFeed and are cloned before being\n // given to any of the actual calls, so these tracks don't actually go\n // anywhere. Let's do it anyway to avoid confusion.\n setTracksEnabled(this.localCallFeed.stream.getAudioTracks(), !muted);\n } else {\n logger.log(`GroupCall ${this.groupCallId} setMicrophoneMuted() no stream muted (muted=${muted})`);\n this.initWithAudioMuted = muted;\n }\n\n this.forEachCall((call) =>\n setTracksEnabled(call.localUsermediaFeed!.stream.getAudioTracks(), !muted && this.callExpected(call)),\n );\n this.emit(GroupCallEvent.LocalMuteStateChanged, muted, this.isLocalVideoMuted());\n\n if (!sendUpdatesBefore) await sendUpdates();\n\n return true;\n }\n\n /**\n * If we allow entering a call without a camera and without video, it can happen that the access rights to the\n * devices have not yet been queried. If a stream does not yet have an audio track, we assume that the rights have\n * not yet been checked.\n *\n * `this.client.getMediaHandler().getUserMediaStream` clones the current stream, so it only wanted to be called when\n * not Audio Track exists.\n * As such, this is a compromise, because, the access rights should always be queried before the call.\n */\n private async checkAudioPermissionIfNecessary(muted: boolean): Promise<boolean> {\n // We needed this here to avoid an error in case user join a call without a device.\n try {\n if (!muted && this.localCallFeed && !this.localCallFeed.hasAudioTrack) {\n const stream = await this.client\n .getMediaHandler()\n .getUserMediaStream(true, !this.localCallFeed.isVideoMuted());\n if (stream?.getTracks().length === 0) {\n // if case permission denied to get a stream stop this here\n /* istanbul ignore next */\n logger.log(\n `GroupCall ${this.groupCallId} setMicrophoneMuted() no device to receive local stream, muted=${muted}`,\n );\n return false;\n }\n }\n } catch {\n /* istanbul ignore next */\n logger.log(\n `GroupCall ${this.groupCallId} setMicrophoneMuted() no device or permission to receive local stream, muted=${muted}`,\n );\n return false;\n }\n\n return true;\n }\n\n /**\n * Sets the mute state of the local participants's video.\n * @param muted - Whether to mute the video\n * @returns Whether muting/unmuting was successful\n */\n public async setLocalVideoMuted(muted: boolean): Promise<boolean> {\n // hasAudioDevice can block indefinitely if the window has lost focus,\n // and it doesn't make much sense to keep a device from being muted, so\n // we always allow muted = true changes to go through\n if (!muted && !(await this.client.getMediaHandler().hasVideoDevice())) {\n return false;\n }\n\n if (this.localCallFeed) {\n /* istanbul ignore next */\n logger.log(\n `GroupCall ${this.groupCallId} setLocalVideoMuted() (stream=${this.localCallFeed.stream.id}, muted=${muted})`,\n );\n\n try {\n const stream = await this.client.getMediaHandler().getUserMediaStream(true, !muted);\n await this.updateLocalUsermediaStream(stream);\n this.localCallFeed.setAudioVideoMuted(null, muted);\n setTracksEnabled(this.localCallFeed.stream.getVideoTracks(), !muted);\n } catch {\n // No permission to video device\n /* istanbul ignore next */\n logger.log(\n `GroupCall ${this.groupCallId} setLocalVideoMuted() no device or permission to receive local stream, muted=${muted}`,\n );\n return false;\n }\n } else {\n logger.log(`GroupCall ${this.groupCallId} setLocalVideoMuted() no stream muted (muted=${muted})`);\n this.initWithVideoMuted = muted;\n }\n\n const updates: Promise<unknown>[] = [];\n this.forEachCall((call) => updates.push(call.setLocalVideoMuted(muted)));\n await Promise.all(updates);\n\n // We setTracksEnabled again, independently from the call doing it\n // internally, since we might not be expecting the call\n this.forEachCall((call) =>\n setTracksEnabled(call.localUsermediaFeed!.stream.getVideoTracks(), !muted && this.callExpected(call)),\n );\n\n this.emit(GroupCallEvent.LocalMuteStateChanged, this.isMicrophoneMuted(), muted);\n\n return true;\n }\n\n public async setScreensharingEnabled(enabled: boolean, opts: IScreensharingOpts = {}): Promise<boolean> {\n if (enabled === this.isScreensharing()) {\n return enabled;\n }\n\n if (enabled) {\n try {\n logger.log(\n `GroupCall ${this.groupCallId} setScreensharingEnabled() is asking for screensharing permissions`,\n );\n const stream = await this.client.getMediaHandler().getScreensharingStream(opts);\n\n for (const track of stream.getTracks()) {\n const onTrackEnded = (): void => {\n this.setScreensharingEnabled(false);\n track.removeEventListener(\"ended\", onTrackEnded);\n };\n\n track.addEventListener(\"ended\", onTrackEnded);\n }\n\n logger.log(\n `GroupCall ${this.groupCallId} setScreensharingEnabled() granted screensharing permissions. Setting screensharing enabled on all calls`,\n );\n\n this.localDesktopCapturerSourceId = opts.desktopCapturerSourceId;\n this.localScreenshareFeed = new CallFeed({\n client: this.client,\n roomId: this.room.roomId,\n userId: this.client.getUserId()!,\n deviceId: this.client.getDeviceId()!,\n stream,\n purpose: SDPStreamMetadataPurpose.Screenshare,\n audioMuted: false,\n videoMuted: false,\n });\n this.addScreenshareFeed(this.localScreenshareFeed);\n\n this.emit(\n GroupCallEvent.LocalScreenshareStateChanged,\n true,\n this.localScreenshareFeed,\n this.localDesktopCapturerSourceId,\n );\n\n // TODO: handle errors\n this.forEachCall((call) => call.pushLocalFeed(this.localScreenshareFeed!.clone()));\n\n return true;\n } catch (error) {\n if (opts.throwOnFail) throw error;\n logger.error(\n `GroupCall ${this.groupCallId} setScreensharingEnabled() enabling screensharing error`,\n error,\n );\n this.emit(\n GroupCallEvent.Error,\n new GroupCallError(\n GroupCallErrorCode.NoUserMedia,\n \"Failed to get screen-sharing stream: \",\n error as Error,\n ),\n );\n return false;\n }\n } else {\n this.forEachCall((call) => {\n if (call.localScreensharingFeed) call.removeLocalFeed(call.localScreensharingFeed);\n });\n this.client.getMediaHandler().stopScreensharingStream(this.localScreenshareFeed!.stream);\n this.removeScreenshareFeed(this.localScreenshareFeed!);\n this.localScreenshareFeed = undefined;\n this.localDesktopCapturerSourceId = undefined;\n this.emit(GroupCallEvent.LocalScreenshareStateChanged, false, undefined, undefined);\n return false;\n }\n }\n\n public isScreensharing(): boolean {\n return !!this.localScreenshareFeed;\n }\n\n /*\n * Call Setup\n *\n * There are two different paths for calls to be created:\n * 1. Incoming calls triggered by the Call.incoming event.\n * 2. Outgoing calls to the initial members of a room or new members\n * as they are observed by the RoomState.members event.\n */\n\n private onIncomingCall = (newCall: MatrixCall): void => {\n // The incoming calls may be for another room, which we will ignore.\n if (newCall.roomId !== this.room.roomId) {\n return;\n }\n\n if (newCall.state !== CallState.Ringing) {\n logger.warn(\n `GroupCall ${this.groupCallId} onIncomingCall() incoming call no longer in ringing state - ignoring`,\n );\n return;\n }\n\n if (!newCall.groupCallId || newCall.groupCallId !== this.groupCallId) {\n logger.log(\n `GroupCall ${this.groupCallId} onIncomingCall() ignored because it doesn't match the current group call`,\n );\n newCall.reject();\n return;\n }\n\n const opponentUserId = newCall.getOpponentMember()?.userId;\n if (opponentUserId === undefined) {\n logger.warn(`GroupCall ${this.groupCallId} onIncomingCall() incoming call with no member - ignoring`);\n return;\n }\n\n if (this.useLivekit) {\n logger.info(\"Received incoming call whilst in signaling-only mode! Ignoring.\");\n return;\n }\n\n const deviceMap = this.calls.get(opponentUserId) ?? new Map<string, MatrixCall>();\n const prevCall = deviceMap.get(newCall.getOpponentDeviceId()!);\n\n if (prevCall?.callId === newCall.callId) return;\n\n logger.log(\n `GroupCall ${this.groupCallId} onIncomingCall() incoming call (userId=${opponentUserId}, callId=${newCall.callId})`,\n );\n\n if (prevCall) prevCall.hangup(CallErrorCode.Replaced, false);\n // We must do this before we start initialising / answering the call as we\n // need to know it is the active call for this user+deviceId and to not ignore\n // events from it.\n deviceMap.set(newCall.getOpponentDeviceId()!, newCall);\n this.calls.set(opponentUserId, deviceMap);\n\n this.initCall(newCall);\n\n const feeds = this.getLocalFeeds().map((feed) => feed.clone());\n if (!this.callExpected(newCall)) {\n // Disable our tracks for users not explicitly participating in the\n // call but trying to receive the feeds\n for (const feed of feeds) {\n setTracksEnabled(feed.stream.getAudioTracks(), false);\n setTracksEnabled(feed.stream.getVideoTracks(), false);\n }\n }\n newCall.answerWithCallFeeds(feeds);\n\n this.emit(GroupCallEvent.CallsChanged, this.calls);\n };\n\n /**\n * Determines whether a given participant expects us to call them (versus\n * them calling us).\n * @param userId - The participant's user ID.\n * @param deviceId - The participant's device ID.\n * @returns Whether we need to place an outgoing call to the participant.\n */\n private wantsOutgoingCall(userId: string, deviceId: string): boolean {\n const localUserId = this.client.getUserId()!;\n const localDeviceId = this.client.getDeviceId()!;\n return (\n // If a user's ID is less than our own, they'll call us\n userId >= localUserId &&\n // If this is another one of our devices, compare device IDs to tell whether it'll call us\n (userId !== localUserId || deviceId > localDeviceId)\n );\n }\n\n /**\n * Places calls to all participants that we're responsible for calling.\n */\n private placeOutgoingCalls(): void {\n let callsChanged = false;\n\n for (const [{ userId }, participantMap] of this.participants) {\n const callMap = this.calls.get(userId) ?? new Map<string, MatrixCall>();\n\n for (const [deviceId, participant] of participantMap) {\n const prevCall = callMap.get(deviceId);\n\n if (\n prevCall?.getOpponentSessionId() !== participant.sessionId &&\n this.wantsOutgoingCall(userId, deviceId)\n ) {\n callsChanged = true;\n\n if (prevCall !== undefined) {\n logger.debug(\n `GroupCall ${this.groupCallId} placeOutgoingCalls() replacing call (userId=${userId}, deviceId=${deviceId}, callId=${prevCall.callId})`,\n );\n prevCall.hangup(CallErrorCode.NewSession, false);\n }\n\n const newCall = createNewMatrixCall(this.client, this.room.roomId, {\n invitee: userId,\n opponentDeviceId: deviceId,\n opponentSessionId: participant.sessionId,\n groupCallId: this.groupCallId,\n });\n\n if (newCall === null) {\n logger.error(\n `GroupCall ${this.groupCallId} placeOutgoingCalls() failed to create call (userId=${userId}, device=${deviceId})`,\n );\n callMap.delete(deviceId);\n } else {\n this.initCall(newCall);\n callMap.set(deviceId, newCall);\n\n logger.debug(\n `GroupCall ${this.groupCallId} placeOutgoingCalls() placing call (userId=${userId}, deviceId=${deviceId}, sessionId=${participant.sessionId})`,\n );\n\n newCall\n .placeCallWithCallFeeds(\n this.getLocalFeeds().map((feed) => feed.clone()),\n participant.screensharing,\n )\n .then(() => {\n if (this.dataChannelsEnabled) {\n newCall.createDataChannel(\"datachannel\", this.dataChannelOptions);\n }\n })\n .catch((e) => {\n logger.warn(\n `GroupCall ${this.groupCallId} placeOutgoingCalls() failed to place call (userId=${userId})`,\n e,\n );\n\n if (e instanceof CallError && e.code === GroupCallErrorCode.UnknownDevice) {\n this.emit(GroupCallEvent.Error, e);\n } else {\n this.emit(\n GroupCallEvent.Error,\n new GroupCallError(\n GroupCallErrorCode.PlaceCallFailed,\n `Failed to place call to ${userId}`,\n ),\n );\n }\n\n newCall.hangup(CallErrorCode.SignallingFailed, false);\n if (callMap.get(deviceId) === newCall) callMap.delete(deviceId);\n });\n }\n }\n }\n\n if (callMap.size > 0) {\n this.calls.set(userId, callMap);\n } else {\n this.calls.delete(userId);\n }\n }\n\n if (callsChanged) this.emit(GroupCallEvent.CallsChanged, this.calls);\n }\n\n /*\n * Room Member State\n */\n\n private getMemberStateEvents(): MatrixEvent[];\n private getMemberStateEvents(userId: string): MatrixEvent | null;\n private getMemberStateEvents(userId?: string): MatrixEvent[] | MatrixEvent | null {\n return userId === undefined\n ? this.room.currentState.getStateEvents(EventType.GroupCallMemberPrefix)\n : this.room.currentState.getStateEvents(EventType.GroupCallMemberPrefix, userId);\n }\n\n private onRetryCallLoop = (): void => {\n let needsRetry = false;\n\n for (const [{ userId }, participantMap] of this.participants) {\n const callMap = this.calls.get(userId);\n let retriesMap = this.retryCallCounts.get(userId);\n\n for (const [deviceId, participant] of participantMap) {\n const call = callMap?.get(deviceId);\n const retries = retriesMap?.get(deviceId) ?? 0;\n\n if (\n call?.getOpponentSessionId() !== participant.sessionId &&\n this.wantsOutgoingCall(userId, deviceId) &&\n retries < 3\n ) {\n if (retriesMap === undefined) {\n retriesMap = new Map();\n this.retryCallCounts.set(userId, retriesMap);\n }\n retriesMap.set(deviceId, retries + 1);\n needsRetry = true;\n }\n }\n }\n\n if (needsRetry) this.placeOutgoingCalls();\n };\n\n private initCall(call: MatrixCall): void {\n const opponentMemberId = getCallUserId(call);\n\n if (!opponentMemberId) {\n throw new Error(\"Cannot init call without user id\");\n }\n\n const onCallFeedsChanged = (): void => this.onCallFeedsChanged(call);\n const onCallStateChanged = (state: CallState, oldState?: CallState): void =>\n this.onCallStateChanged(call, state, oldState);\n const onCallHangup = this.onCallHangup;\n const onCallReplaced = (newCall: MatrixCall): void => this.onCallReplaced(call, newCall);\n\n let deviceMap = this.callHandlers.get(opponentMemberId);\n if (deviceMap === undefined) {\n deviceMap = new Map();\n this.callHandlers.set(opponentMemberId, deviceMap);\n }\n\n deviceMap.set(call.getOpponentDeviceId()!, {\n onCallFeedsChanged,\n onCallStateChanged,\n onCallHangup,\n onCallReplaced,\n });\n\n call.on(CallEvent.FeedsChanged, onCallFeedsChanged);\n call.on(CallEvent.State, onCallStateChanged);\n call.on(CallEvent.Hangup, onCallHangup);\n call.on(CallEvent.Replaced, onCallReplaced);\n\n call.isPtt = this.isPtt;\n\n this.reEmitter.reEmit(call, Object.values(CallEvent));\n\n call.initStats(this.getGroupCallStats());\n\n onCallFeedsChanged();\n }\n\n private disposeCall(call: MatrixCall, hangupReason: CallErrorCode): void {\n const opponentMemberId = getCallUserId(call);\n const opponentDeviceId = call.getOpponentDeviceId()!;\n\n if (!opponentMemberId) {\n throw new Error(\"Cannot dispose call without user id\");\n }\n\n const deviceMap = this.callHandlers.get(opponentMemberId)!;\n const { onCallFeedsChanged, onCallStateChanged, onCallHangup, onCallReplaced } =\n deviceMap.get(opponentDeviceId)!;\n\n call.removeListener(CallEvent.FeedsChanged, onCallFeedsChanged);\n call.removeListener(CallEvent.State, onCallStateChanged);\n call.removeListener(CallEvent.Hangup, onCallHangup);\n call.removeListener(CallEvent.Replaced, onCallReplaced);\n\n deviceMap.delete(opponentMemberId);\n if (deviceMap.size === 0) this.callHandlers.delete(opponentMemberId);\n\n if (call.hangupReason === CallErrorCode.Replaced) {\n return;\n }\n\n const usermediaFeed = this.getUserMediaFeed(opponentMemberId, opponentDeviceId);\n\n if (usermediaFeed) {\n this.removeUserMediaFeed(usermediaFeed);\n }\n\n const screenshareFeed = this.getScreenshareFeed(opponentMemberId, opponentDeviceId);\n\n if (screenshareFeed) {\n this.removeScreenshareFeed(screenshareFeed);\n }\n }\n\n private onCallFeedsChanged = (call: MatrixCall): void => {\n const opponentMemberId = getCallUserId(call);\n const opponentDeviceId = call.getOpponentDeviceId()!;\n\n if (!opponentMemberId) {\n throw new Error(\"Cannot change call feeds without user id\");\n }\n\n const currentUserMediaFeed = this.getUserMediaFeed(opponentMemberId, opponentDeviceId);\n const remoteUsermediaFeed = call.remoteUsermediaFeed;\n const remoteFeedChanged = remoteUsermediaFeed !== currentUserMediaFeed;\n\n const deviceMap = this.calls.get(opponentMemberId);\n const currentCallForUserDevice = deviceMap?.get(opponentDeviceId);\n if (currentCallForUserDevice?.callId !== call.callId) {\n // the call in question is not the current call for this user/deviceId\n // so ignore feed events from it otherwise we'll remove our real feeds\n return;\n }\n\n if (remoteFeedChanged) {\n if (!currentUserMediaFeed && remoteUsermediaFeed) {\n this.addUserMediaFeed(remoteUsermediaFeed);\n } else if (currentUserMediaFeed && remoteUsermediaFeed) {\n this.replaceUserMediaFeed(currentUserMediaFeed, remoteUsermediaFeed);\n } else if (currentUserMediaFeed && !remoteUsermediaFeed) {\n this.removeUserMediaFeed(currentUserMediaFeed);\n }\n }\n\n const currentScreenshareFeed = this.getScreenshareFeed(opponentMemberId, opponentDeviceId);\n const remoteScreensharingFeed = call.remoteScreensharingFeed;\n const remoteScreenshareFeedChanged = remoteScreensharingFeed !== currentScreenshareFeed;\n\n if (remoteScreenshareFeedChanged) {\n if (!currentScreenshareFeed && remoteScreensharingFeed) {\n this.addScreenshareFeed(remoteScreensharingFeed);\n } else if (currentScreenshareFeed && remoteScreensharingFeed) {\n this.replaceScreenshareFeed(currentScreenshareFeed, remoteScreensharingFeed);\n } else if (currentScreenshareFeed && !remoteScreensharingFeed) {\n this.removeScreenshareFeed(currentScreenshareFeed);\n }\n }\n };\n\n private onCallStateChanged = (call: MatrixCall, state: CallState, _oldState: CallState | undefined): void => {\n if (state === CallState.Ended) return;\n\n const audioMuted = this.localCallFeed!.isAudioMuted();\n\n if (call.localUsermediaStream && call.isMicrophoneMuted() !== audioMuted) {\n call.setMicrophoneMuted(audioMuted);\n }\n\n const videoMuted = this.localCallFeed!.isVideoMuted();\n\n if (call.localUsermediaStream && call.isLocalVideoMuted() !== videoMuted) {\n call.setLocalVideoMuted(videoMuted);\n }\n\n const opponentUserId = call.getOpponentMember()?.userId;\n if (state === CallState.Connected && opponentUserId) {\n const retriesMap = this.retryCallCounts.get(opponentUserId);\n retriesMap?.delete(call.getOpponentDeviceId()!);\n if (retriesMap?.size === 0) this.retryCallCounts.delete(opponentUserId);\n }\n };\n\n private onCallHangup = (call: MatrixCall): void => {\n if (call.hangupReason === CallErrorCode.Replaced) return;\n\n const opponentUserId = call.getOpponentMember()?.userId ?? this.room.getMember(call.invitee!)!.userId;\n const deviceMap = this.calls.get(opponentUserId);\n\n // Sanity check that this call is in fact in the map\n if (deviceMap?.get(call.getOpponentDeviceId()!) === call) {\n this.disposeCall(call, call.hangupReason as CallErrorCode);\n deviceMap.delete(call.getOpponentDeviceId()!);\n if (deviceMap.size === 0) this.calls.delete(opponentUserId);\n this.emit(GroupCallEvent.CallsChanged, this.calls);\n }\n };\n\n private onCallReplaced = (prevCall: MatrixCall, newCall: MatrixCall): void => {\n const opponentUserId = prevCall.getOpponentMember()!.userId;\n\n let deviceMap = this.calls.get(opponentUserId);\n if (deviceMap === undefined) {\n deviceMap = new Map();\n this.calls.set(opponentUserId, deviceMap);\n }\n\n prevCall.hangup(CallErrorCode.Replaced, false);\n this.initCall(newCall);\n deviceMap.set(prevCall.getOpponentDeviceId()!, newCall);\n this.emit(GroupCallEvent.CallsChanged, this.calls);\n };\n\n /*\n * UserMedia CallFeed Event Handlers\n */\n\n public getUserMediaFeed(userId: string, deviceId: string): CallFeed | undefined {\n return this.userMediaFeeds.find((f) => f.userId === userId && f.deviceId! === deviceId);\n }\n\n private addUserMediaFeed(callFeed: CallFeed): void {\n this.userMediaFeeds.push(callFeed);\n callFeed.measureVolumeActivity(true);\n this.emit(GroupCallEvent.UserMediaFeedsChanged, this.userMediaFeeds);\n }\n\n private replaceUserMediaFeed(existingFeed: CallFeed, replacementFeed: CallFeed): void {\n const feedIndex = this.userMediaFeeds.findIndex(\n (f) => f.userId === existingFeed.userId && f.deviceId! === existingFeed.deviceId,\n );\n\n if (feedIndex === -1) {\n throw new Error(\"Couldn't find user media feed to replace\");\n }\n\n this.userMediaFeeds.splice(feedIndex, 1, replacementFeed);\n\n existingFeed.dispose();\n replacementFeed.measureVolumeActivity(true);\n this.emit(GroupCallEvent.UserMediaFeedsChanged, this.userMediaFeeds);\n }\n\n private removeUserMediaFeed(callFeed: CallFeed): void {\n const feedIndex = this.userMediaFeeds.findIndex(\n (f) => f.userId === callFeed.userId && f.deviceId! === callFeed.deviceId,\n );\n\n if (feedIndex === -1) {\n throw new Error(\"Couldn't find user media feed to remove\");\n }\n\n this.userMediaFeeds.splice(feedIndex, 1);\n\n callFeed.dispose();\n this.emit(GroupCallEvent.UserMediaFeedsChanged, this.userMediaFeeds);\n\n if (this.activeSpeaker === callFeed) {\n this.activeSpeaker = this.userMediaFeeds[0];\n this.emit(GroupCallEvent.ActiveSpeakerChanged, this.activeSpeaker);\n }\n }\n\n private onActiveSpeakerLoop = (): void => {\n let topAvg: number | undefined = undefined;\n let nextActiveSpeaker: CallFeed | undefined = undefined;\n\n for (const callFeed of this.userMediaFeeds) {\n if (callFeed.isLocal() && this.userMediaFeeds.length > 1) continue;\n\n const total = callFeed.speakingVolumeSamples.reduce(\n (acc, volume) => acc + Math.max(volume, SPEAKING_THRESHOLD),\n );\n const avg = total / callFeed.speakingVolumeSamples.length;\n\n if (!topAvg || avg > topAvg) {\n topAvg = avg;\n nextActiveSpeaker = callFeed;\n }\n }\n\n if (nextActiveSpeaker && this.activeSpeaker !== nextActiveSpeaker && topAvg && topAvg > SPEAKING_THRESHOLD) {\n this.activeSpeaker = nextActiveSpeaker;\n this.emit(GroupCallEvent.ActiveSpeakerChanged, this.activeSpeaker);\n }\n };\n\n /*\n * Screenshare Call Feed Event Handlers\n */\n\n public getScreenshareFeed(userId: string, deviceId: string): CallFeed | undefined {\n return this.screenshareFeeds.find((f) => f.userId === userId && f.deviceId! === deviceId);\n }\n\n private addScreenshareFeed(callFeed: CallFeed): void {\n this.screenshareFeeds.push(callFeed);\n this.emit(GroupCallEvent.ScreenshareFeedsChanged, this.screenshareFeeds);\n }\n\n private replaceScreenshareFeed(existingFeed: CallFeed, replacementFeed: CallFeed): void {\n const feedIndex = this.screenshareFeeds.findIndex(\n (f) => f.userId === existingFeed.userId && f.deviceId! === existingFeed.deviceId,\n );\n\n if (feedIndex === -1) {\n throw new Error(\"Couldn't find screenshare feed to replace\");\n }\n\n this.screenshareFeeds.splice(feedIndex, 1, replacementFeed);\n\n existingFeed.dispose();\n this.emit(GroupCallEvent.ScreenshareFeedsChanged, this.screenshareFeeds);\n }\n\n private removeScreenshareFeed(callFeed: CallFeed): void {\n const feedIndex = this.screenshareFeeds.findIndex(\n (f) => f.userId === callFeed.userId && f.deviceId! === callFeed.deviceId,\n );\n\n if (feedIndex === -1) {\n throw new Error(\"Couldn't find screenshare feed to remove\");\n }\n\n this.screenshareFeeds.splice(feedIndex, 1);\n\n callFeed.dispose();\n this.emit(GroupCallEvent.ScreenshareFeedsChanged, this.screenshareFeeds);\n }\n\n /**\n * Recalculates and updates the participant map to match the room state.\n */\n private updateParticipants(): void {\n const localMember = this.room.getMember(this.client.getUserId()!)!;\n if (!localMember) {\n // The client hasn't fetched enough of the room state to get our own member\n // event. This probably shouldn't happen, but sanity check & exit for now.\n logger.warn(\n `GroupCall ${this.groupCallId} updateParticipants() tried to update participants before local room member is available`,\n );\n return;\n }\n\n if (this.participantsExpirationTimer !== null) {\n clearTimeout(this.participantsExpirationTimer);\n this.participantsExpirationTimer = null;\n }\n\n if (this.state === GroupCallState.Ended) {\n this.participants = new Map();\n return;\n }\n\n const participants = new Map<RoomMember, Map<string, ParticipantState>>();\n const now = Date.now();\n const entered = this.state === GroupCallState.Entered || this.enteredViaAnotherSession;\n let nextExpiration = Infinity;\n\n for (const e of this.getMemberStateEvents()) {\n const member = this.room.getMember(e.getStateKey()!);\n const content = e.getContent<Record<any, unknown>>();\n const calls: Record<any, unknown>[] = Array.isArray(content[\"m.calls\"]) ? content[\"m.calls\"] : [];\n const call = calls.find((call) => call[\"m.call_id\"] === this.groupCallId);\n const devices: Record<any, unknown>[] = Array.isArray(call?.[\"m.devices\"]) ? call![\"m.devices\"] : [];\n\n // Filter out invalid and expired devices\n let validDevices = devices.filter(\n (d) =>\n typeof d.device_id === \"string\" &&\n typeof d.session_id === \"string\" &&\n typeof d.expires_ts === \"number\" &&\n d.expires_ts > now &&\n Array.isArray(d.feeds),\n ) as unknown as IGroupCallRoomMemberDevice[];\n\n // Apply local echo for the unentered case\n if (!entered && member?.userId === this.client.getUserId()!) {\n validDevices = validDevices.filter((d) => d.device_id !== this.client.getDeviceId()!);\n }\n\n // Must have a connected device and be joined to the room\n if (validDevices.length > 0 && member?.membership === KnownMembership.Join) {\n const deviceMap = new Map<string, ParticipantState>();\n participants.set(member, deviceMap);\n\n for (const d of validDevices) {\n deviceMap.set(d.device_id, {\n sessionId: d.session_id,\n screensharing: d.feeds.some((f) => f.purpose === SDPStreamMetadataPurpose.Screenshare),\n });\n if (d.expires_ts < nextExpiration) nextExpiration = d.expires_ts;\n }\n }\n }\n\n // Apply local echo for the entered case\n if (entered) {\n let deviceMap = participants.get(localMember);\n if (deviceMap === undefined) {\n deviceMap = new Map();\n participants.set(localMember, deviceMap);\n }\n\n if (!deviceMap.has(this.client.getDeviceId()!)) {\n deviceMap.set(this.client.getDeviceId()!, {\n sessionId: this.client.getSessionId(),\n screensharing: this.getLocalFeeds().some((f) => f.purpose === SDPStreamMetadataPurpose.Screenshare),\n });\n }\n }\n\n this.participants = participants;\n if (nextExpiration < Infinity) {\n this.participantsExpirationTimer = setTimeout(() => this.updateParticipants(), nextExpiration - now);\n }\n }\n\n /**\n * Updates the local user's member state with the devices returned by the given function.\n * @param fn - A function from the current devices to the new devices. If it\n * returns null, the update will be skipped.\n * @param keepAlive - Whether the request should outlive the window.\n */\n private async updateDevices(\n fn: (devices: IGroupCallRoomMemberDevice[]) => IGroupCallRoomMemberDevice[] | null,\n keepAlive = false,\n ): Promise<void> {\n const now = Date.now();\n const localUserId = this.client.getUserId()!;\n\n const event = this.getMemberStateEvents(localUserId);\n const content = event?.getContent<Record<any, unknown>>() ?? {};\n const calls: Record<any, unknown>[] = Array.isArray(content[\"m.calls\"]) ? content[\"m.calls\"] : [];\n\n let call: Record<any, unknown> | null = null;\n const otherCalls: Record<any, unknown>[] = [];\n for (const c of calls) {\n if (c[\"m.call_id\"] === this.groupCallId) {\n call = c;\n } else {\n otherCalls.push(c);\n }\n }\n if (call === null) call = {};\n\n const devices: Record<any, unknown>[] = Array.isArray(call[\"m.devices\"]) ? call[\"m.devices\"] : [];\n\n // Filter out invalid and expired devices\n const validDevices = devices.filter(\n (d) =>\n typeof d.device_id === \"string\" &&\n typeof d.session_id === \"string\" &&\n typeof d.expires_ts === \"number\" &&\n d.expires_ts > now &&\n Array.isArray(d.feeds),\n ) as unknown as IGroupCallRoomMemberDevice[];\n\n const newDevices = fn(validDevices);\n if (newDevices === null) return;\n\n const newCalls = [...(otherCalls as unknown as IGroupCallRoomMemberCallState[])];\n if (newDevices.length > 0) {\n newCalls.push({\n ...call,\n \"m.call_id\": this.groupCallId,\n \"m.devices\": newDevices,\n });\n }\n\n const newContent: IGroupCallRoomMemberState = { \"m.calls\": newCalls };\n\n await this.client.sendStateEvent(this.room.roomId, EventType.GroupCallMemberPrefix, newContent, localUserId, {\n keepAlive,\n });\n }\n\n private async addDeviceToMemberState(): Promise<void> {\n await this.updateDevices((devices) => [\n ...devices.filter((d) => d.device_id !== this.client.getDeviceId()!),\n {\n device_id: this.client.getDeviceId()!,\n session_id: this.client.getSessionId(),\n expires_ts: Date.now() + DEVICE_TIMEOUT,\n feeds: this.getLocalFeeds().map((feed) => ({ purpose: feed.purpose })),\n // TODO: Add data channels\n },\n ]);\n }\n\n private async updateMemberState(): Promise<void> {\n // Clear the old update interval before proceeding\n if (this.resendMemberStateTimer !== null) {\n clearInterval(this.resendMemberStateTimer);\n this.resendMemberStateTimer = null;\n }\n\n if (this.state === GroupCallState.Entered) {\n // Add the local device\n await this.addDeviceToMemberState();\n\n // Resend the state event every so often so it doesn't become stale\n this.resendMemberStateTimer = setInterval(\n async () => {\n logger.log(`GroupCall ${this.groupCallId} updateMemberState() resending call member state\"`);\n try {\n await this.addDeviceToMemberState();\n } catch (e) {\n logger.error(\n `GroupCall ${this.groupCallId} updateMemberState() failed to resend call member state`,\n e,\n );\n }\n },\n (DEVICE_TIMEOUT * 3) / 4,\n );\n } else {\n // Remove the local device\n await this.updateDevices(\n (devices) => devices.filter((d) => d.device_id !== this.client.getDeviceId()!),\n true,\n );\n }\n }\n\n /**\n * Cleans up our member state by filtering out logged out devices, inactive\n * devices, and our own device (if we know we haven't entered).\n */\n public async cleanMemberState(): Promise<void> {\n const { devices: myDevices } = await this.client.getDevices();\n const deviceMap = new Map<string, IMyDevice>(myDevices.map((d) => [d.device_id, d]));\n\n // updateDevices takes care of filtering out inactive devices for us\n await this.updateDevices((devices) => {\n const newDevices = devices.filter((d) => {\n const device = deviceMap.get(d.device_id);\n return (\n device?.last_seen_ts !== undefined &&\n !(\n d.device_id === this.client.getDeviceId()! &&\n this.state !== GroupCallState.Entered &&\n !this.enteredViaAnotherSession\n )\n );\n });\n\n // Skip the update if the devices are unchanged\n return newDevices.length === devices.length ? null : newDevices;\n });\n }\n\n private onRoomState = (): void => this.updateParticipants();\n\n private onParticipantsChanged = (): void => {\n // Re-run setTracksEnabled on all calls, so that participants that just\n // left get denied access to our media, and participants that just\n // joined get granted access\n this.forEachCall((call) => {\n const expected = this.callExpected(call);\n for (const feed of call.getLocalFeeds()) {\n setTracksEnabled(feed.stream.getAudioTracks(), !feed.isAudioMuted() && expected);\n setTracksEnabled(feed.stream.getVideoTracks(), !feed.isVideoMuted() && expected);\n }\n });\n\n if (this.state === GroupCallState.Entered && !this.useLivekit) this.placeOutgoingCalls();\n\n // Update the participants stored in the stats object\n };\n\n private onStateChanged = (newState: GroupCallState, oldState: GroupCallState): void => {\n if (\n newState === GroupCallState.Entered ||\n oldState === GroupCallState.Entered ||\n newState === GroupCallState.Ended\n ) {\n // We either entered, left, or ended the call\n this.updateParticipants();\n this.updateMemberState().catch((e) =>\n logger.error(\n `GroupCall ${this.groupCallId} onStateChanged() failed to update member state devices\"`,\n e,\n ),\n );\n }\n };\n\n private onLocalFeedsChanged = (): void => {\n if (this.state === GroupCallState.Entered) {\n this.updateMemberState().catch((e) =>\n logger.error(\n `GroupCall ${this.groupCallId} onLocalFeedsChanged() failed to update member state feeds`,\n e,\n ),\n );\n }\n };\n\n public getGroupCallStats(): GroupCallStats {\n if (this.stats === undefined) {\n const userID = this.client.getUserId() || \"unknown\";\n this.stats = new GroupCallStats(this.groupCallId, userID, this.statsCollectIntervalTime);\n this.stats.reports.on(StatsReport.CONNECTION_STATS, this.onConnectionStats);\n this.stats.reports.on(StatsReport.BYTE_SENT_STATS, this.onByteSentStats);\n this.stats.reports.on(StatsReport.SUMMARY_STATS, this.onSummaryStats);\n this.stats.reports.on(StatsReport.CALL_FEED_REPORT, this.onCallFeedReport);\n }\n return this.stats;\n }\n\n public setGroupCallStatsInterval(interval: number): void {\n this.statsCollectIntervalTime = interval;\n if (this.stats !== undefined) {\n this.stats.stop();\n this.stats.setInterval(interval);\n if (interval > 0) {\n this.stats.start();\n }\n }\n }\n}\n"],"mappings":";;;;AAAA,SAASA,iBAAiB,QAAQ,kCAAkC;AACpE,SAASC,QAAQ,EAAEC,kBAAkB,QAAQ,eAAe;AAE5D,SACIC,aAAa,EACbC,SAAS,EAETC,SAAS,EACTC,SAAS,EAETC,gBAAgB,EAChBC,mBAAmB,EACnBC,SAAS,Q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C;MAC3E,IAAI,CAAChJ,KAAK,CAAC8I,OAAO,CAAC3O,EAAE,CAAClL,WAAW,CAACga,eAAe,EAAE,IAAI,CAACC,eAAe,CAAC;MACxE,IAAI,CAAClJ,KAAK,CAAC8I,OAAO,CAAC3O,EAAE,CAAClL,WAAW,CAACka,aAAa,EAAE,IAAI,CAACC,cAAc,CAAC;MACrE,IAAI,CAACpJ,KAAK,CAAC8I,OAAO,CAAC3O,EAAE,CAAClL,WAAW,CAACoa,gBAAgB,EAAE,IAAI,CAACC,gBAAgB,CAAC;IAC9E;IACA,OAAO,IAAI,CAACtJ,KAAK;EACrB;EAEOuJ,yBAAyBA,CAACC,QAAgB,EAAQ;IACrD,IAAI,CAACX,wBAAwB,GAAGW,QAAQ;IACxC,IAAI,IAAI,CAACxJ,KAAK,KAAKpO,SAAS,EAAE;MAC1B,IAAI,CAACoO,KAAK,CAACC,IAAI,CAAC,CAAC;MACjB,IAAI,CAACD,KAAK,CAAClB,WAAW,CAAC0K,QAAQ,CAAC;MAChC,IAAIA,QAAQ,GAAG,CAAC,EAAE;QACd,IAAI,CAACxJ,KAAK,CAACyJ,KAAK,CAAC,CAAC;MACtB;IACJ;EACJ;AACJ","ignoreList":[]}
@@ -1,31 +0,0 @@
1
- import { MatrixClient } from "../client.ts";
2
- import { GroupCall } from "./groupCall.ts";
3
- import { RoomMember } from "../models/room-member.ts";
4
- export declare enum GroupCallEventHandlerEvent {
5
- Incoming = "GroupCall.incoming",
6
- Outgoing = "GroupCall.outgoing",
7
- Ended = "GroupCall.ended",
8
- Participants = "GroupCall.participants"
9
- }
10
- export type GroupCallEventHandlerEventHandlerMap = {
11
- [GroupCallEventHandlerEvent.Incoming]: (call: GroupCall) => void;
12
- [GroupCallEventHandlerEvent.Outgoing]: (call: GroupCall) => void;
13
- [GroupCallEventHandlerEvent.Ended]: (call: GroupCall) => void;
14
- [GroupCallEventHandlerEvent.Participants]: (participants: RoomMember[], call: GroupCall) => void;
15
- };
16
- export declare class GroupCallEventHandler {
17
- private client;
18
- groupCalls: Map<string, GroupCall>;
19
- private roomDeferreds;
20
- constructor(client: MatrixClient);
21
- start(): Promise<void>;
22
- stop(): void;
23
- private getRoomDeferred;
24
- waitUntilRoomReadyForGroupCalls(roomId: string): Promise<void>;
25
- getGroupCallById(groupCallId: string): GroupCall | undefined;
26
- private createGroupCallForRoom;
27
- private createGroupCallFromRoomStateEvent;
28
- private onRoomsChanged;
29
- private onRoomStateChanged;
30
- }
31
- //# sourceMappingURL=groupCallEventHandler.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"groupCallEventHandler.d.ts","sourceRoot":"","sources":["../../src/webrtc/groupCallEventHandler.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,YAAY,EAAe,MAAM,cAAc,CAAC;AACzD,OAAO,EAAE,SAAS,EAAgE,MAAM,gBAAgB,CAAC;AAGzG,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAKtD,oBAAY,0BAA0B;IAClC,QAAQ,uBAAuB;IAC/B,QAAQ,uBAAuB;IAC/B,KAAK,oBAAoB;IACzB,YAAY,2BAA2B;CAC1C;AAED,MAAM,MAAM,oCAAoC,GAAG;IAC/C,CAAC,0BAA0B,CAAC,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,SAAS,KAAK,IAAI,CAAC;IACjE,CAAC,0BAA0B,CAAC,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,SAAS,KAAK,IAAI,CAAC;IACjE,CAAC,0BAA0B,CAAC,KAAK,CAAC,EAAE,CAAC,IAAI,EAAE,SAAS,KAAK,IAAI,CAAC;IAC9D,CAAC,0BAA0B,CAAC,YAAY,CAAC,EAAE,CAAC,YAAY,EAAE,UAAU,EAAE,EAAE,IAAI,EAAE,SAAS,KAAK,IAAI,CAAC;CACpG,CAAC;AAOF,qBAAa,qBAAqB;IASX,OAAO,CAAC,MAAM;IAR1B,UAAU,yBAAgC;IAMjD,OAAO,CAAC,aAAa,CAAmC;gBAE7B,MAAM,EAAE,YAAY;IAElC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IA6B5B,IAAI,IAAI,IAAI;IAKnB,OAAO,CAAC,eAAe;IAgBhB,+BAA+B,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAI9D,gBAAgB,CAAC,WAAW,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS;IAInE,OAAO,CAAC,sBAAsB;IAwB9B,OAAO,CAAC,iCAAiC;IA+DzC,OAAO,CAAC,cAAc,CAEpB;IAEF,OAAO,CAAC,kBAAkB,CA2BxB;CACL"}
@@ -1,178 +0,0 @@
1
- import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
2
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
- /*
4
- Copyright 2021 Šimon Brandner <simon.bra.ag@gmail.com>
5
-
6
- Licensed under the Apache License, Version 2.0 (the "License");
7
- you may not use this file except in compliance with the License.
8
- You may obtain a copy of the License at
9
-
10
- http://www.apache.org/licenses/LICENSE-2.0
11
-
12
- Unless required by applicable law or agreed to in writing, software
13
- distributed under the License is distributed on an "AS IS" BASIS,
14
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- See the License for the specific language governing permissions and
16
- limitations under the License.
17
- */
18
-
19
- import { ClientEvent } from "../client.js";
20
- import { GroupCall, GroupCallIntent, GroupCallType } from "./groupCall.js";
21
- import { RoomStateEvent } from "../models/room-state.js";
22
- import { logger } from "../logger.js";
23
- import { EventType } from "../@types/event.js";
24
- import { SyncState } from "../sync.js";
25
- export var GroupCallEventHandlerEvent = /*#__PURE__*/function (GroupCallEventHandlerEvent) {
26
- GroupCallEventHandlerEvent["Incoming"] = "GroupCall.incoming";
27
- GroupCallEventHandlerEvent["Outgoing"] = "GroupCall.outgoing";
28
- GroupCallEventHandlerEvent["Ended"] = "GroupCall.ended";
29
- GroupCallEventHandlerEvent["Participants"] = "GroupCall.participants";
30
- return GroupCallEventHandlerEvent;
31
- }({});
32
- export class GroupCallEventHandler {
33
- constructor(client) {
34
- this.client = client;
35
- _defineProperty(this, "groupCalls", new Map());
36
- // roomId -> GroupCall
37
- // All rooms we know about and whether we've seen a 'Room' event
38
- // for them. The promise will be fulfilled once we've processed that
39
- // event which means we're "up to date" on what calls are in a room
40
- // and get
41
- _defineProperty(this, "roomDeferreds", new Map());
42
- _defineProperty(this, "onRoomsChanged", room => {
43
- this.createGroupCallForRoom(room);
44
- });
45
- _defineProperty(this, "onRoomStateChanged", (event, state) => {
46
- var eventType = event.getType();
47
- if (eventType === EventType.GroupCallPrefix) {
48
- var groupCallId = event.getStateKey();
49
- var content = event.getContent();
50
- var currentGroupCall = this.groupCalls.get(state.roomId);
51
- if (!currentGroupCall && !content["m.terminated"] && !event.isRedacted()) {
52
- this.createGroupCallFromRoomStateEvent(event);
53
- } else if (currentGroupCall && currentGroupCall.groupCallId === groupCallId) {
54
- if (content["m.terminated"] || event.isRedacted()) {
55
- currentGroupCall.terminate(false);
56
- } else if (content["m.type"] !== currentGroupCall.type) {
57
- // TODO: Handle the callType changing when the room state changes
58
- logger.warn("GroupCallEventHandler onRoomStateChanged() currently does not support changing type (roomId=".concat(state.roomId, ")"));
59
- }
60
- } else if (currentGroupCall && currentGroupCall.groupCallId !== groupCallId) {
61
- // TODO: Handle new group calls and multiple group calls
62
- logger.warn("GroupCallEventHandler onRoomStateChanged() currently does not support multiple calls (roomId=".concat(state.roomId, ")"));
63
- }
64
- }
65
- });
66
- }
67
- start() {
68
- var _this = this;
69
- return _asyncToGenerator(function* () {
70
- // We wait until the client has started syncing for real.
71
- // This is because we only support one call at a time, and want
72
- // the latest. We therefore want the latest state of the room before
73
- // we create a group call for the room so we can be fairly sure that
74
- // the group call we create is really the latest one.
75
- if (_this.client.getSyncState() !== SyncState.Syncing) {
76
- logger.debug("GroupCallEventHandler start() waiting for client to start syncing");
77
- yield new Promise(resolve => {
78
- var onSync = () => {
79
- if (_this.client.getSyncState() === SyncState.Syncing) {
80
- _this.client.off(ClientEvent.Sync, onSync);
81
- return resolve();
82
- }
83
- };
84
- _this.client.on(ClientEvent.Sync, onSync);
85
- });
86
- }
87
- var rooms = _this.client.getRooms();
88
- for (var room of rooms) {
89
- _this.createGroupCallForRoom(room);
90
- }
91
- _this.client.on(ClientEvent.Room, _this.onRoomsChanged);
92
- _this.client.on(RoomStateEvent.Events, _this.onRoomStateChanged);
93
- })();
94
- }
95
- stop() {
96
- this.client.removeListener(ClientEvent.Room, this.onRoomsChanged);
97
- this.client.removeListener(RoomStateEvent.Events, this.onRoomStateChanged);
98
- }
99
- getRoomDeferred(roomId) {
100
- var deferred = this.roomDeferreds.get(roomId);
101
- if (deferred === undefined) {
102
- var resolveFunc;
103
- deferred = {
104
- prom: new Promise(resolve => {
105
- resolveFunc = resolve;
106
- })
107
- };
108
- deferred.resolve = resolveFunc;
109
- this.roomDeferreds.set(roomId, deferred);
110
- }
111
- return deferred;
112
- }
113
- waitUntilRoomReadyForGroupCalls(roomId) {
114
- return this.getRoomDeferred(roomId).prom;
115
- }
116
- getGroupCallById(groupCallId) {
117
- return [...this.groupCalls.values()].find(groupCall => groupCall.groupCallId === groupCallId);
118
- }
119
- createGroupCallForRoom(room) {
120
- var callEvents = room.currentState.getStateEvents(EventType.GroupCallPrefix);
121
- var sortedCallEvents = callEvents.sort((a, b) => b.getTs() - a.getTs());
122
- for (var callEvent of sortedCallEvents) {
123
- var content = callEvent.getContent();
124
- if (content["m.terminated"] || callEvent.isRedacted()) {
125
- continue;
126
- }
127
- logger.debug("GroupCallEventHandler createGroupCallForRoom() choosing group call from possible calls (stateKey=".concat(callEvent.getStateKey(), ", ts=").concat(callEvent.getTs(), ", roomId=").concat(room.roomId, ", numOfPossibleCalls=").concat(callEvents.length, ")"));
128
- this.createGroupCallFromRoomStateEvent(callEvent);
129
- break;
130
- }
131
- this.getRoomDeferred(room.roomId).resolve();
132
- }
133
- createGroupCallFromRoomStateEvent(event) {
134
- var roomId = event.getRoomId();
135
- var content = event.getContent();
136
- var room = this.client.getRoom(roomId);
137
- if (!room) {
138
- logger.warn("GroupCallEventHandler createGroupCallFromRoomStateEvent() couldn't find room for call (roomId=".concat(roomId, ")"));
139
- return;
140
- }
141
- var groupCallId = event.getStateKey();
142
- var callType = content["m.type"];
143
- if (!Object.values(GroupCallType).includes(callType)) {
144
- logger.warn("GroupCallEventHandler createGroupCallFromRoomStateEvent() received invalid call type (type=".concat(callType, ", roomId=").concat(roomId, ")"));
145
- return;
146
- }
147
- var callIntent = content["m.intent"];
148
- if (!Object.values(GroupCallIntent).includes(callIntent)) {
149
- logger.warn("Received invalid group call intent (type=".concat(callType, ", roomId=").concat(roomId, ")"));
150
- return;
151
- }
152
- var isPtt = Boolean(content["io.element.ptt"]);
153
- var dataChannelOptions;
154
- if (content !== null && content !== void 0 && content.dataChannelsEnabled && content !== null && content !== void 0 && content.dataChannelOptions) {
155
- // Pull out just the dataChannelOptions we want to support.
156
- var {
157
- ordered,
158
- maxPacketLifeTime,
159
- maxRetransmits,
160
- protocol
161
- } = content.dataChannelOptions;
162
- dataChannelOptions = {
163
- ordered,
164
- maxPacketLifeTime,
165
- maxRetransmits,
166
- protocol
167
- };
168
- }
169
- var groupCall = new GroupCall(this.client, room, callType, isPtt, callIntent, groupCallId,
170
- // Because without Media section a WebRTC connection is not possible, so need a RTCDataChannel to set up a
171
- // no media WebRTC connection anyway.
172
- (content === null || content === void 0 ? void 0 : content.dataChannelsEnabled) || this.client.isVoipWithNoMediaAllowed, dataChannelOptions, this.client.isVoipWithNoMediaAllowed, this.client.useLivekitForGroupCalls, content["io.element.livekit_service_url"]);
173
- this.groupCalls.set(room.roomId, groupCall);
174
- this.client.emit(GroupCallEventHandlerEvent.Incoming, groupCall);
175
- return groupCall;
176
- }
177
- }
178
- //# sourceMappingURL=groupCallEventHandler.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"groupCallEventHandler.js","names":["ClientEvent","GroupCall","GroupCallIntent","GroupCallType","RoomStateEvent","logger","EventType","SyncState","GroupCallEventHandlerEvent","GroupCallEventHandler","constructor","client","_defineProperty","Map","room","createGroupCallForRoom","event","state","eventType","getType","GroupCallPrefix","groupCallId","getStateKey","content","getContent","currentGroupCall","groupCalls","get","roomId","isRedacted","createGroupCallFromRoomStateEvent","terminate","type","warn","concat","start","_this","_asyncToGenerator","getSyncState","Syncing","debug","Promise","resolve","onSync","off","Sync","on","rooms","getRooms","Room","onRoomsChanged","Events","onRoomStateChanged","stop","removeListener","getRoomDeferred","deferred","roomDeferreds","undefined","resolveFunc","prom","set","waitUntilRoomReadyForGroupCalls","getGroupCallById","values","find","groupCall","callEvents","currentState","getStateEvents","sortedCallEvents","sort","a","b","getTs","callEvent","length","getRoomId","getRoom","callType","Object","includes","callIntent","isPtt","Boolean","dataChannelOptions","dataChannelsEnabled","ordered","maxPacketLifeTime","maxRetransmits","protocol","isVoipWithNoMediaAllowed","useLivekitForGroupCalls","emit","Incoming"],"sources":["../../src/webrtc/groupCallEventHandler.ts"],"sourcesContent":["/*\nCopyright 2021 Šimon Brandner <simon.bra.ag@gmail.com>\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\nimport { MatrixEvent } from \"../models/event.ts\";\nimport { MatrixClient, ClientEvent } from \"../client.ts\";\nimport { GroupCall, GroupCallIntent, GroupCallType, IGroupCallDataChannelOptions } from \"./groupCall.ts\";\nimport { Room } from \"../models/room.ts\";\nimport { RoomState, RoomStateEvent } from \"../models/room-state.ts\";\nimport { RoomMember } from \"../models/room-member.ts\";\nimport { logger } from \"../logger.ts\";\nimport { EventType } from \"../@types/event.ts\";\nimport { SyncState } from \"../sync.ts\";\n\nexport enum GroupCallEventHandlerEvent {\n Incoming = \"GroupCall.incoming\",\n Outgoing = \"GroupCall.outgoing\",\n Ended = \"GroupCall.ended\",\n Participants = \"GroupCall.participants\",\n}\n\nexport type GroupCallEventHandlerEventHandlerMap = {\n [GroupCallEventHandlerEvent.Incoming]: (call: GroupCall) => void;\n [GroupCallEventHandlerEvent.Outgoing]: (call: GroupCall) => void;\n [GroupCallEventHandlerEvent.Ended]: (call: GroupCall) => void;\n [GroupCallEventHandlerEvent.Participants]: (participants: RoomMember[], call: GroupCall) => void;\n};\n\ninterface RoomDeferred {\n prom: Promise<void>;\n resolve?: () => void;\n}\n\nexport class GroupCallEventHandler {\n public groupCalls = new Map<string, GroupCall>(); // roomId -> GroupCall\n\n // All rooms we know about and whether we've seen a 'Room' event\n // for them. The promise will be fulfilled once we've processed that\n // event which means we're \"up to date\" on what calls are in a room\n // and get\n private roomDeferreds = new Map<string, RoomDeferred>();\n\n public constructor(private client: MatrixClient) {}\n\n public async start(): Promise<void> {\n // We wait until the client has started syncing for real.\n // This is because we only support one call at a time, and want\n // the latest. We therefore want the latest state of the room before\n // we create a group call for the room so we can be fairly sure that\n // the group call we create is really the latest one.\n if (this.client.getSyncState() !== SyncState.Syncing) {\n logger.debug(\"GroupCallEventHandler start() waiting for client to start syncing\");\n await new Promise<void>((resolve) => {\n const onSync = (): void => {\n if (this.client.getSyncState() === SyncState.Syncing) {\n this.client.off(ClientEvent.Sync, onSync);\n return resolve();\n }\n };\n this.client.on(ClientEvent.Sync, onSync);\n });\n }\n\n const rooms = this.client.getRooms();\n\n for (const room of rooms) {\n this.createGroupCallForRoom(room);\n }\n\n this.client.on(ClientEvent.Room, this.onRoomsChanged);\n this.client.on(RoomStateEvent.Events, this.onRoomStateChanged);\n }\n\n public stop(): void {\n this.client.removeListener(ClientEvent.Room, this.onRoomsChanged);\n this.client.removeListener(RoomStateEvent.Events, this.onRoomStateChanged);\n }\n\n private getRoomDeferred(roomId: string): RoomDeferred {\n let deferred = this.roomDeferreds.get(roomId);\n if (deferred === undefined) {\n let resolveFunc: () => void;\n deferred = {\n prom: new Promise<void>((resolve) => {\n resolveFunc = resolve;\n }),\n };\n deferred.resolve = resolveFunc!;\n this.roomDeferreds.set(roomId, deferred);\n }\n\n return deferred;\n }\n\n public waitUntilRoomReadyForGroupCalls(roomId: string): Promise<void> {\n return this.getRoomDeferred(roomId).prom;\n }\n\n public getGroupCallById(groupCallId: string): GroupCall | undefined {\n return [...this.groupCalls.values()].find((groupCall) => groupCall.groupCallId === groupCallId);\n }\n\n private createGroupCallForRoom(room: Room): void {\n const callEvents = room.currentState.getStateEvents(EventType.GroupCallPrefix);\n const sortedCallEvents = callEvents.sort((a, b) => b.getTs() - a.getTs());\n\n for (const callEvent of sortedCallEvents) {\n const content = callEvent.getContent();\n\n if (content[\"m.terminated\"] || callEvent.isRedacted()) {\n continue;\n }\n\n logger.debug(\n `GroupCallEventHandler createGroupCallForRoom() choosing group call from possible calls (stateKey=${callEvent.getStateKey()}, ts=${callEvent.getTs()}, roomId=${\n room.roomId\n }, numOfPossibleCalls=${callEvents.length})`,\n );\n\n this.createGroupCallFromRoomStateEvent(callEvent);\n break;\n }\n\n this.getRoomDeferred(room.roomId).resolve!();\n }\n\n private createGroupCallFromRoomStateEvent(event: MatrixEvent): GroupCall | undefined {\n const roomId = event.getRoomId();\n const content = event.getContent();\n\n const room = this.client.getRoom(roomId);\n\n if (!room) {\n logger.warn(\n `GroupCallEventHandler createGroupCallFromRoomStateEvent() couldn't find room for call (roomId=${roomId})`,\n );\n return;\n }\n\n const groupCallId = event.getStateKey();\n\n const callType = content[\"m.type\"];\n\n if (!Object.values(GroupCallType).includes(callType)) {\n logger.warn(\n `GroupCallEventHandler createGroupCallFromRoomStateEvent() received invalid call type (type=${callType}, roomId=${roomId})`,\n );\n return;\n }\n\n const callIntent = content[\"m.intent\"];\n\n if (!Object.values(GroupCallIntent).includes(callIntent)) {\n logger.warn(`Received invalid group call intent (type=${callType}, roomId=${roomId})`);\n return;\n }\n\n const isPtt = Boolean(content[\"io.element.ptt\"]);\n\n let dataChannelOptions: IGroupCallDataChannelOptions | undefined;\n\n if (content?.dataChannelsEnabled && content?.dataChannelOptions) {\n // Pull out just the dataChannelOptions we want to support.\n const { ordered, maxPacketLifeTime, maxRetransmits, protocol } = content.dataChannelOptions;\n dataChannelOptions = { ordered, maxPacketLifeTime, maxRetransmits, protocol };\n }\n\n const groupCall = new GroupCall(\n this.client,\n room,\n callType,\n isPtt,\n callIntent,\n groupCallId,\n // Because without Media section a WebRTC connection is not possible, so need a RTCDataChannel to set up a\n // no media WebRTC connection anyway.\n content?.dataChannelsEnabled || this.client.isVoipWithNoMediaAllowed,\n dataChannelOptions,\n this.client.isVoipWithNoMediaAllowed,\n this.client.useLivekitForGroupCalls,\n content[\"io.element.livekit_service_url\"],\n );\n\n this.groupCalls.set(room.roomId, groupCall);\n this.client.emit(GroupCallEventHandlerEvent.Incoming, groupCall);\n\n return groupCall;\n }\n\n private onRoomsChanged = (room: Room): void => {\n this.createGroupCallForRoom(room);\n };\n\n private onRoomStateChanged = (event: MatrixEvent, state: RoomState): void => {\n const eventType = event.getType();\n\n if (eventType === EventType.GroupCallPrefix) {\n const groupCallId = event.getStateKey();\n const content = event.getContent();\n\n const currentGroupCall = this.groupCalls.get(state.roomId);\n\n if (!currentGroupCall && !content[\"m.terminated\"] && !event.isRedacted()) {\n this.createGroupCallFromRoomStateEvent(event);\n } else if (currentGroupCall && currentGroupCall.groupCallId === groupCallId) {\n if (content[\"m.terminated\"] || event.isRedacted()) {\n currentGroupCall.terminate(false);\n } else if (content[\"m.type\"] !== currentGroupCall.type) {\n // TODO: Handle the callType changing when the room state changes\n logger.warn(\n `GroupCallEventHandler onRoomStateChanged() currently does not support changing type (roomId=${state.roomId})`,\n );\n }\n } else if (currentGroupCall && currentGroupCall.groupCallId !== groupCallId) {\n // TODO: Handle new group calls and multiple group calls\n logger.warn(\n `GroupCallEventHandler onRoomStateChanged() currently does not support multiple calls (roomId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