TECH7Fox / sip-hass-card

A SIP client inside home assistant!
MIT License
189 stars 39 forks source link

Add button to mute the local microphone #33

Closed nanosonde closed 2 years ago

nanosonde commented 2 years ago

As a user of the sip card I would like to be able to mute the local microphone on my wall-mounted tablet while I am in a call with the frontdoor SIP-based doorbell so that I can talk to other people next to me in the house without being heared by the person in front of the door.

See this discussion: https://github.com/onsip/SIP.js/issues/492

TECH7Fox commented 2 years ago

Will add this feature.

Also, I now read from your link that you can get the audio tracks with session.getLocalStreams()[0].getAudioTracks() which is exactly what I was missing to implement the audio visualizer, so thanks! 😄

nanosonde commented 2 years ago

Great. ;-)

But keep in mind that getLocalStreams() is marked deprecated.

It seems one have to use this now:

const pc: any = this.session.sessionDescriptionHandler.peerConnection
    pc.getSenders().forEach((stream: any) => {
      stream.track.enabled = false
    })
nanosonde commented 2 years ago

There is also a muting example given in the offical documentation: https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnection/getSenders

TECH7Fox commented 2 years ago

But keep in mind that getLocalStreams() is marked deprecated.

Ah, thanks, will use that way then.

Muting option shouldn't be too hard to implement, will let you know how it goes.