versatica / JsSIP

JsSIP, the JavaScript SIP library
https://jssip.net
Other
2.4k stars 738 forks source link

Error when trying to change the microphone during a call #849

Closed SPDSirGuiL closed 5 months ago

SPDSirGuiL commented 5 months ago

I'm having problems changing the microphone during the call, using this code:

` const localStream = session.connection.getLocalStreams()[0] const audioTracks = localStream.getAudioTracks()

audioTracks.forEach((track: MediaStreamTrack) => { track.stop() })

const constraints = { audio: { deviceId: { exact: microphoneId } }, }

navigator.mediaDevices .getUserMedia(constraints) .then((newStream) => { session.connection.removeStream(localStream) session.connection.addStream(newStream)

  const renegotiationOptions = {
    useUpdate: true,
    mediaStream: newStream,
    mediaConstraints: { audio: constraints },
    RTCOfferOptions: { audio: constraints },
  }

  session.renegotiate(renegotiationOptions, () => {
    console.log('Sessão renegociada com sucesso.')
  })
})
.catch((error) => {
  console.error('Erro ao alterar o dispositivo de áudio:', error)
})

`

But there is completely no sound from the microphone when using this. How do I change the microphone during the call?

ibc commented 5 months ago

Please don't use GitHub issues to make usage questions, use the JsSIP public mailing list.