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

CF SDK: Negotiate callee media based on the Remote SDP #1125

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

iAmmar7
Copy link
Collaborator

@iAmmar7 iAmmar7 commented Oct 7, 2024

Description

The CF SDK handles the Caller user media based on the destination address channel. This PR will now handle the Callee user media based on the incoming/remote SDP.

Additional changes;

  • Set the outgoing video negotiation based on the destination address channel but give more priority to user-passed params.
  • Remove handling media based on the remote SDP part from the generic getMediaConstraints function to remove the dependency and keep it a generic method.

Type of change

  • Internal refactoring
  • Bug fix (bugfix - non-breaking)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Code snippets

No changes are required from the client side.

Copy link

changeset-bot bot commented Oct 7, 2024

🦋 Changeset detected

Latest commit: 02d1cf2

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@signalwire/webrtc Patch
@signalwire/js Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@iAmmar7 iAmmar7 requested a review from jpsantosbh October 7, 2024 14:21
const call = this.wsClient.makeCallFabricObject({
audio: params.audio ?? true,
video: params.video ?? video,
negotiateAudio: params.negotiateAudio ?? true,
Copy link
Collaborator

Choose a reason for hiding this comment

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

The remote SDP needs to be considered for audio, too.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Makes sense to me, thanks! 👍 I am gonna update this.

audio: params.audio ?? true,
video: params.video ?? video,
negotiateAudio: params.negotiateAudio ?? true,
negotiateVideo: params.negotiateVideo ?? negotiateVideo,
Copy link
Collaborator

Choose a reason for hiding this comment

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

The developer shouldn't be allowed to override the SDP terms.

@iAmmar7 iAmmar7 requested a review from jpsantosbh October 7, 2024 15:45
}

const call = this.wsClient.makeCallFabricObject({
audio: params.audio ?? audio,
Copy link
Collaborator

Choose a reason for hiding this comment

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

ATM, we can't let the params take precedence or we will get the onnegotiationneeded loop.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ummm... this is a self user's outgoing audio/video stream. This does not affect the SDP. It's just the local stream.

The negotiate params are below. Am I missing something?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes, exactly, but if the remote SDP doesn't accept video or audio we don't want to:
a) waste resources opening the unsupported media in for the localStream
b) add an unsupported media track to the RTPPeerConnection (to avoid the onn loop)

The final SDP negotiation depends on whether the localStream has the media tracks or whether we decide to negotiate the media even without the tracks.

But in cases where the remote SDP doesn't support a type of media, we don't want to force a renegotiation.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That's what I am trying to understand; the negotiate params used in the SDP for the media negotiation are the below two params, or not?

Also, if we do not accept the audio and video params from the developer, would that be a good user experience? Considering that the callee may want to answer the audio-only call with his video open.

Maybe we should reconsider and try to reproduce the loopback scenario to understand which parameters affect the SDP.

Copy link
Collaborator

Choose a reason for hiding this comment

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

SDP for the media negotiation are the below two params, or not?
It's both the local media (influenced by video and audio params) and negotiateVideo, negotiatedAudio.

I agree it isn't the best user experience, but since the SDK and the backend don't support the required renegotiation ATM. We have no option but to ignore the parameter in that case.

You can reproduce the issue by creating an audio-only call to a subscriber and having the App to set video:true when answering.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

At the moment, I am unable to reproduce any of the above. It seems no matter what I pass while dialing a call, the server always sends the remote SDP to the callee including both video and audio. As far as a local video is concerned, the SDK opens the camera based on the video param.

Let's put it on hold, we might want to discuss this with the RTC.

Copy link
Collaborator

@jpsantosbh jpsantosbh left a comment

Choose a reason for hiding this comment

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

To prevent an accidental merge. In the current form, these changes will create a regression.

@jpsantosbh jpsantosbh mentioned this pull request Oct 14, 2024
4 tasks
@iAmmar7 iAmmar7 marked this pull request as draft October 16, 2024 11:48
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.

2 participants