Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Group Calls (WIP) #1902

Closed
wants to merge 218 commits into from
Closed

Group Calls (WIP) #1902

wants to merge 218 commits into from

Conversation

robertlong
Copy link
Contributor

@robertlong robertlong commented Sep 9, 2021

Group Calls

This PR expands upon Matrix calls and adds support for establishing calls to multiple members in a room. The code stems from my work on matrix-video-chat.

New Classes

GroupCall

Created by calling client.createGroupCall(roomId, type) where type can be either "voice" or "video". This class essentially sets up a bunch of MatrixCalls to room members who have set a participant state event.

GroupCallParticipant

This is a wrapper around MatrixCall that represents the state for a participant who has entered a GroupCall.

New Features

Addition of the invitee field to m.call.invite

This invitee field allows the recipients of the m.call.invite event to filter out invites not intended for them.

Ice Disconnected Timeout

Rather than wait on the Ice failed connection state, I added a 30 second timeout which ensures that calls hang up if you've been disconnected for too long. If the connection state changes within this 30 second period, this timeout resets.

Active Speaker

@SimonBrandner recently added speaking and volume events to CallFeeds, this PR uses that work to track the "active speaker" in a group call. This is primarily intended to be used to show what user should be focused in a group call.

WebRTC Datachannels

Adding datachannels to calls is currently possible by calling call.peerConn.createDataChannel(). This PR just formalizes that process by adding a public API method for doing so and a datachannel event for listening for new datachannels on a MatrixCall or GroupCall.

To Do:

  • Split out unrelated code into separate PRs
  • Refactor getLocalAudioStream/ getLocalVideoStream
  • Revert CallFeed export
  • Figure out final conference call join/leave/presence events (device events etc.)
  • Write an MSC for the new group call events and invitee field.
  • Fix known regression with microphone/video mute state
  • Add docs for all new public methods/strings/classes
  • Write release notes

This PR currently has no changelog labels, so will not be included in changelogs.

A reviewer can add one of: T-Deprecation, T-Enhancement, T-Defect, T-Task to indicate what type of change this is, or add Type: [enhancement/defect/task] to the description and I'll add them for you.

src/client.ts Outdated Show resolved Hide resolved
src/client.ts Outdated Show resolved Hide resolved
src/matrix.ts Outdated Show resolved Hide resolved
src/webrtc/call.ts Outdated Show resolved Hide resolved
src/webrtc/callFeed.ts Show resolved Hide resolved
}

const CONF_ROOM = "me.robertlong.conf";
const CONF_PARTICIPANT = "me.robertlong.conf.participant";
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO: I need to move this to the proper MSC event once we've created it.

*/

// TODO: move this elsewhere or get rid of the retry logic. Do we need it?
sendStateEventWithRetry(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't actually know that we still want this for this PR. I don't think it was actually making calls any more stable, but I don't know for sure.

@SimonBrandner SimonBrandner self-requested a review September 10, 2021 14:45
Copy link
Contributor

@SimonBrandner SimonBrandner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally, this looking absolutely awesome! I'll do a more thorough review when this isn't a draft but I've got a few more general points:

  • It might be beneficial for localParticipant to be a getter the same way localUserMediaStream and similar are
  • GroupCall should emit feeds_changed events and have a getFeeds() method which is more friendly for making CallView components. It might even allow us to make the already existing CallView in the react-sdk work without many changes
  • The TypeScript could be improved a bit (params and return types)
  • MediaHandler from Improve MatrixCall media handling and internally remove CallTypes #1911 should be somehow used when it gets merged

src/webrtc/groupCall.ts Show resolved Hide resolved
src/webrtc/groupCall.ts Outdated Show resolved Hide resolved
@@ -630,6 +630,11 @@ export class MatrixCall extends EventEmitter {
* @param {boolean} addToPeerConnection whether to add the tracks to the peer connection
*/
public pushLocalFeed(callFeed: CallFeed, addToPeerConnection = true): void {
if (this.feeds.some((feed) => callFeed.stream.id === feed.stream.id)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the same stream id always mean the same feed?

robertlong and others added 23 commits February 10, 2022 10:31
No particular reason to worry about old user agents here
Seems chrome at least will give you a disabled audio track if you
already had another user media audio track and disabled it, so make
sure our tracks are enabled when we add them. We already did this
on one code path but it didn't get moved over when a new code path
was added.

On the plus side, we now know the reason for the ancient code that
had the comment asking what it was for, so update that.
If a renogotiation ends up with one track being removed, we removed
the whole stream, which would cause us to lose, for example, audio
rather than just video.
* Add PTT call mode & mute by default in PTT calls (#2311)

No other parts of PTT calls implemented yet

* Make the tests pass again (#2316)

3280394
made call use a bunch of methods that weren't mocked in the tests.

* Add maximum trasmit time for PTT (#2312)

on sender side by muting mic after the max transmit time has elapsed.

* Don't allow user to unmute if another user is speaking  (#2313)

* Add maximum trasmit time for PTT

on sender side by muting mic after the max transmit time has elapsed.

* Don't allow user to unmute if another user is speaking

Based on #2312
For element-hq/element-call#298

* Fix createGroupCall arguments (#2325)

Comma instead of a colon...
@dbkr dbkr mentioned this pull request May 9, 2022
@dbkr
Copy link
Member

dbkr commented May 10, 2022

Closing in favour of #2355

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants