signalwire / signalwire-js

MIT License
18 stars 15 forks source link

Renegotiate media with different directions #1137

Open iAmmar7 opened 1 month ago

iAmmar7 commented 1 month ago

Description

ref: https://github.com/signalwire/cloud-product/issues/11648 & https://github.com/signalwire/signalwire-js/pull/1132

Allow users to renegotiate video, including the downgrade/upgrade of the RTC media peers.

Type of change

Code snippets

// Enable audio with "sendrecv" direction
await call.enableAudio()

// Enable audio with "sendonly" direction
await call.enableAudio({ audio: true, negotiateAudio: false })

// Enable audio with "recvonly" direction
await call.enableAudio({ audio: false, negotiateAudio: true })

// Disable audio while keeps on receiving it
await call.disableAudio({ negotiateAudio: true })

// Disable audio completely
await call.disableAudio()

// Enable video with "sendrecv" direction
await call.enableVideo()

// Enable video with "sendonly" direction
await call.enableVideo({ video: true, negotiateVideo: false })

// Enable video with "recvonly" direction
await call.enableVideo({ video: false, negotiateVideo: true })

// Disable video while keeps on receiving it
await call.disableVideo({ negotiateVideo: true })

// Disable video completely
await call.disableVideo()
changeset-bot[bot] commented 1 month ago

🦋 Changeset detected

Latest commit: bca43b8ea4bd199efc9bd26cec255cae73aadbfc

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 | Minor | | @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 commented 1 month ago

@jpsantosbh @giavac I would appreciate it if you guys run this locally and test the WebRTC internals. I have added a bunch of e2e tests but still, if you guys see abnormalities in the WebRTC internals, please do let me know.

To test the media upgrades/downgrades, you may run the following methods inside the browser console.

// To enable
__call.enableVideo();

// To disable
__call.disableVideo();

Method params are mentioned in the PR description.