If the client uses a widget to join group calls, like Element Web does, then the local device could be joined to the call without GroupCall knowing. This adds a field to GroupCall that allows the client to tell GroupCall when it's using another session to join the call.
This refactoring brings a number of improvements to GroupCall, which I've unfortunately had to combine into a single commit due to coupling:
- Moves the expiration timestamp field on call membership state to be per-device
- Makes the participants of a group call visible without having to enter the call yourself
- Enables users to join group calls from multiple devices
- Identifies active speakers by their call feed, rather than just their user ID
- Plays nicely with clients that can be in multiple calls in a room at once
- Fixes a memory leak caused by the call retry loop never stopping
- Changes GroupCall to update its state synchronously, and write back to room state asynchronously
- This was already sort of halfway being done, but now we'd be committing to it
- Generally improves the robustness of the state machine
- It means that group call joins will appear instant, in a sense
For many reasons, this is a breaking change.
Unfortunately there are still other methods that could race with leave and result in broken group call state, such as enter and terminate. For the future, should consider writing a more careful specification of how the whole group call state machine is meant to work.
* TS strict mode compliance in the call / groupcall code
* Also the test
* Fix initOpponentCrypto
to not panic if it doesn't actually need to init crypto
* Fix screenshare failing after several attempts
Re-use any existing transceivers when screen sharing. This prevents
transceivers accumulating and making the SDP too big: see linked bug.
This also switches from `addTrack()` to `addTransceiver ()` which is
not that large of a change, other than having to explicitly find the
transceivers after an offer has arrived rather than just adding tracks
and letting WebRTC take care of it.
Fixes https://github.com/vector-im/element-call/issues/625
* Fix tests
* Unused import
* Use a map instead of an array
* Add comment
* more comment
* Remove commented code
* Remove unintentional debugging
* Add test for screenshare transceiver re-use
* Type alias for transceiver map
* Fix race in creating calls
We ran an async function between checking for an existing call and
adding the new one to the map, so it would have been possible to
start creating another call while we were placing the first call.
This changes the code to add the call to the map as soon as we've
created it.
Also adds more logging.
* Switch to logger.debug
* Fix unit tests
* MediaHandler Tests, part 1
Haven't got through all the methods yet
For https://github.com/vector-im/element-call/issues/544
* Didn't need these in the end
* Rest of the media handler tests
* getUserMediaStream takes args
* use mockResolvedValue
* Add .off & reuse the mock we already made
* Re-use mock handler again
* Move updateLocalUsermediaStream to beforeEach
* add .off
* Add types
* Add more .offs
* Add types to the call unit test suites
Still involves quite a few casts to any unfortunately as it turns
out we access quite a few private methods on the Call class in these
tests.
* Remove commented line & use better expect syntax
* Replace more calls.length with toHaveBeenCalled
* Remove mistakenly added id field
* 1:1 screenshare tests
Fixes https://github.com/vector-im/element-call/issues/548
* Always hang up calls after tests
to prevent hanging tests
Also fix a null dereference as we may not have an invitee or opponent
member when sending voip events if not using to-device messages.
* use mockImplementationOnce
Co-authored-by: Robin <robin@robin.town>
* use mockImplementationOnce
Co-authored-by: Robin <robin@robin.town>
* Add type on mock
* Add corresponding call.off
* Merge enable & disable screenshare tests
Co-authored-by: Robin <robin@robin.town>