Repository navigation
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On an incoming call that has not been answered yet,
RTCSession.mute()throws aTypeError.#connectionis still null when#toggleMuteAudio()callsgetSenders(). This happens on JsSIP 3.6.1 and on currentmaster.The throw leaves the session in a bad state.
mute()sets#audioMuted = truebefore it touches the peer connection, soisMuted()reports muted after the call fails. Once the call is answered, a secondmute()sees the flag already set and skips the senders, so the audio track stays enabled.unmute()has the same ordering: it clears#audioMuted/#videoMutedfirst.Steps to reproduce:
session.mute({ audio: true }). It throwsTypeError, andsession.isMuted().audiois nowtrue.session.mute({ audio: true })again. The local audio track is still enabled.Fix
mute()andunmute()now throwExceptions.InvalidStateErrorbefore changing any state when audio or video is requested and the peer connection does not exist yet.isMuted()stays unchanged. Mute with neither audio nor video stays a no-op. This matcheshold()andunhold(), which already returnfalsewithout changing#localHoldoutsideWAITING_FOR_ACKandCONFIRMED. The doc comments for all four methods now describe this.Tests
The new test in
src/test/test-RTCSession.tsmutes, unmutes and holds an unanswered incoming call, answers it, mutes again and checks that the audio track is disabled.masterwithout the fix, the test fails (1 failing).npm testpasses on macOS, and all 117 tests pass on Linux (Node 22).Fixes #685