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

Enable group calls without video and audio track by configuration of MatrixClient #3162

Merged
merged 16 commits into from
Mar 2, 2023

Conversation

EnricoSchw
Copy link
Contributor

@EnricoSchw EnricoSchw commented Feb 16, 2023

Checklist

  • Tests written for new code (and old code if feasible)
  • Linter and other CI checks pass
  • Sign-off given on the changes (see CONTRIBUTING.md)

Allow Element Call to be started without audio / video interface for the sake of a screen-sharing only session element-hq/element-call#902


Here's what your changelog entry will look like:

✨ Features

  • Enable group calls without video and audio track by configuration of MatrixClient (#3162). Contributed by @EnricoSchw.

}

public set initCallWithoutVideoAndAudio(allowCallWithOutVideoAndAudio: boolean) {
this.allowCallWithOutVideoAndAudio = allowCallWithOutVideoAndAudio;
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not put this into opts and make it readonly and public?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In the beginning createGroupCall from the MatrixClient stopped me from doing that. But since the configuration is now done via the Matrix Client, there is no reason not to do it via the constructor. Thx 👍

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.

I am not exactly confident having this as a flag on the client is the correct way to go though I can't think of alternatives 🤔 Could we quickly go over this in the EC internal room?

Comment on lines 620 to 624
// Because we need a Local Call Feed to establish a call connection, we avoid muting video in case of empty
// video track. In this way we go sure if a client implements muting we don't raise an error.
if (this.initCallWithoutVideoAndAudio && this.localCallFeed?.stream.getVideoTracks().length === 0) {
return false;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry, it's somehow not clear to me what this piece of code does exactly

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My implementation allows feeds that does not contain tracks at all. I have to make sure that the user of the SDK doesn't try to mute a feed that doesn't have a video track. This case must be caught. It would be logically correct if we would have no LocalFeed. This case is covert below. But you need a LocalFeed to innit a GroupCall. I can't go the way of PTT either, because I have to assume that no device exists.

Copy link
Member

Choose a reason for hiding this comment

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

Do we need to check for this.initCallWithoutVideoAndAudio? Wouldn't it always be an error to try & mute/unmute video if there was no video track?

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'll remove it

@EnricoSchw
Copy link
Contributor Author

I am not exactly confident having this as a flag on the client is the correct way to go though I can't think of alternatives 🤔 Could we quickly go over this in the EC internal room?

Technically we could implement a new GroupCall Type in the same way we do this with PTT. After this we can bind it on EC internal room like we do it currently with PTT.

However, I don't think that's a good idea. The SDK is based on Feeds with a video and a audio track. PTT is already working around this and provide Feeds with only audio tracks. The feature I'm implemented should allows calls without Feeds at all. I'am working around this in a way thats I am provide Feeds without audio and without video tracks (but this is not a Feed anymore). However this is a hack, because a User is connected in the call, when we receive a Feed from the user means a Video or Audio Track from him. As long as we don't know exactly what is a Feed and what isn't, it's better to configure this feature separately via the client.

Copy link
Member

@dbkr dbkr left a comment

Choose a reason for hiding this comment

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

I think basically either we add this flag (which does make the logic of calls a bit more complex) or accept that it's no longer an error condition to have a call with no local or remote feeds (ie. basically just make this behaviour the default. I think making it the default could be okay actually: it would be an API change (albeit not a very significant one) but I think that's OK?

Comment on lines 620 to 624
// Because we need a Local Call Feed to establish a call connection, we avoid muting video in case of empty
// video track. In this way we go sure if a client implements muting we don't raise an error.
if (this.initCallWithoutVideoAndAudio && this.localCallFeed?.stream.getVideoTracks().length === 0) {
return false;
}
Copy link
Member

Choose a reason for hiding this comment

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

Do we need to check for this.initCallWithoutVideoAndAudio? Wouldn't it always be an error to try & mute/unmute video if there was no video track?

@EnricoSchw
Copy link
Contributor Author

EnricoSchw commented Feb 22, 2023

I think basically either we add this flag (which does make the logic of calls a bit more complex) or accept that it's no longer an error condition to have a call with no local or remote feeds (ie. basically just make this behaviour the default. I think making it the default could be okay actually: it would be an API change (albeit not a very significant one) but I think that's OK?

I didn't want to change that much and I wanted to keep it very simple, so we can close the ticket (only screen share calls)

This implementation works because no feed is expected if flag active. I have no idea how complicated it will be to add a new GrupenCall type.

@dbkr
Copy link
Member

dbkr commented Feb 23, 2023

Agreed, I don't think adding a new group call type is the way to go. I feel okay about the flag since it leaves 1:1 calls in element web etc in a mode where the call will fail if no media is negotiated, which is probably the sensible thing to do. Perhaps we could put the option either in initLocalCallFeeds or a separate dedicated setter for the option. @SimonBrandner how would you feel about that?

@SimonBrandner
Copy link
Contributor

Agreed, I don't think adding a new group call type is the way to go. I feel okay about the flag since it leaves 1:1 calls in element web etc in a mode where the call will fail if no media is negotiated, which is probably the sensible thing to do. Perhaps we could put the option either in initLocalCallFeeds or a separate dedicated setter for the option. @SimonBrandner how would you feel about that?

Yeah, that sounds good

@EnricoSchw
Copy link
Contributor Author

Agreed, I don't think adding a new group call type is the way to go. I feel okay about the flag since it leaves 1:1 calls in element web etc in a mode where the call will fail if no media is negotiated, which is probably the sensible thing to do. Perhaps we could put the option either in initLocalCallFeeds or a separate dedicated setter for the option.

initCallWithoutVideoAndAudio change the behavior of the whole SDK and not only the behavior of the Feeds.. it should be a main property and not pass by a feed init method.

And because it change the behavior of the SDK its a good idea to path it by constructor, we already have discussed

@EnricoSchw
Copy link
Contributor Author

EnricoSchw commented Feb 24, 2023

Maybe the name initCallWithoutVideoAndAudio is misleading. I will change the name to allowCallWithoutVideoAndAudio. Its then consistent to EC.

@dbkr @SimonBrandner could you agree about it?

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.

Can the code in groupcall.ts be simplified now?

src/webrtc/mediaHandler.ts Outdated Show resolved Hide resolved
src/webrtc/mediaHandler.ts Outdated Show resolved Hide resolved
spec/unit/webrtc/groupCall.spec.ts Show resolved Hide resolved
spec/unit/webrtc/groupCall.spec.ts Show resolved Hide resolved
@EnricoSchw
Copy link
Contributor Author

Can the code in groupcall.ts be simplified now?

@SimonBrandner Can you please be more specific? Do you mean setLocalVideoMuted and setMicrophoneMuted? I would like to use promise.then().catch() instead of try catch blocks, but the linter forbids that.

@EnricoSchw
Copy link
Contributor Author

@dbkr PTAL

@EnricoSchw EnricoSchw added this pull request to the merge queue Mar 2, 2023
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Mar 2, 2023
@EnricoSchw EnricoSchw added this pull request to the merge queue Mar 2, 2023
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Mar 2, 2023
@EnricoSchw EnricoSchw added this pull request to the merge queue Mar 2, 2023
@andybalaam andybalaam removed this pull request from the merge queue due to a manual request Mar 2, 2023
@andybalaam andybalaam added this pull request to the merge queue Mar 2, 2023
@andybalaam
Copy link
Contributor

Apologies for jumping the queue with #3184 - the develop branch was broken due to me force-merging a PR that broke our quality guidelines (because it contained repeated code, to allow us to migrate smoothly from an old to new interface without breaking matrix-react-sdk). The PR I jumped to the front of the queue should unbreak us, meaning this PR can get merged when it gets to the front of the queue.

Merged via the queue into develop with commit e782a2a Mar 2, 2023
@andybalaam andybalaam deleted the enricoschw/group-call-without-video-and-audio branch March 2, 2023 17:17
@t3chguy
Copy link
Member

t3chguy commented Mar 2, 2023

Due to a required parameter being added

@t3chguy
Copy link
Member

t3chguy commented Mar 2, 2023

#3186 brought back backwards compatibility - thanks @EnricoSchw

@t3chguy t3chguy removed T-Task Tasks for the team like planning X-Breaking-Change labels Mar 2, 2023
su-ex added a commit to SchildiChat/matrix-js-sdk that referenced this pull request Mar 15, 2023
* Implement MSC3758: a push rule condition to match event properties exactly ([\matrix-org#3179](matrix-org#3179)).
* Enable group calls without video and audio track by configuration of MatrixClient ([\matrix-org#3162](matrix-org#3162)). Contributed by @EnricoSchw.
* Updates to protocol used for Sign in with QR code ([\matrix-org#3155](matrix-org#3155)). Contributed by @hughns.
* Implement MSC3873 to handle escaped dots in push rule keys ([\matrix-org#3134](matrix-org#3134)). Fixes undefined/matrix-js-sdk#1454.
* Fix spec compliance issue around encrypted `m.relates_to` ([\matrix-org#3178](matrix-org#3178)).
* Fix reactions in threads sometimes causing stuck notifications ([\matrix-org#3146](matrix-org#3146)). Fixes element-hq/element-web#24000. Contributed by @justjanne.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants