onsip / SIP.js

A simple, intuitive, and powerful JavaScript signaling library
https://sipjs.com
MIT License
1.84k stars 693 forks source link

Unable to downgrade call form Video call to Audio call #1076

Open MuneebAhmed568 opened 3 months ago

MuneebAhmed568 commented 3 months ago

File => /src/platform/web/session-description-handler/session-description-handler.ts

protected getLocalMediaStream(options?: SessionDescriptionHandlerOptions): Promise { // ignore constraint "downgrades" constraints.audio = constraints.audio || this.localMediaStreamConstraints.audio; constraints.video = constraints.video || this.localMediaStreamConstraints.video; }

Can you Explain why the developer doesn't allow to downgrade a call from Video to audio call

I SOLVED THIS ISSUE BY THIS

protected getLocalMediaStream(options?: SessionDescriptionHandlerOptions): Promise { // ignore constraint "downgrades" constraints.audio = constraints.audio; constraints.video = constraints.video; }

is this a security issue????

leandl commented 1 month ago

What to understand from the comment // ignore constraint "downgrades", this is something on purpose, now why? God only knows

I don't know if there is something in the core of the project that doesn't allow these 'downgrades', but if it is possible to perform these 'downgrades', it would be better to use the 'Nullish Coalescing Operator', because since the constraints are optional, they might not be passed

Example: If the constraints.audio is not passed, its value would be undefined, because in this case, we only want to change the video, so there should be no change in the audio state.

Example using the Nullish Coalescing Operator:

protected getLocalMediaStream(options?: SessionDescriptionHandlerOptions): Promise {
  constraints.audio = constraints.audio ?? this.localMediaStreamConstraints.audio;
  constraints.video = constraints.video ?? this.localMediaStreamConstraints.video;
}
MuneebAhmed568 commented 4 weeks ago

Thanks for your response. After some testing, I was able to solve this issue. There's no need to downgrade constraints. The solution is to simply stop the video track when it is not needed and replace the track when it needs to be added again. This approach maintains the integrity of the audio state and avoids unnecessary complexity with downgrading constraints.