Play dtmf sounds to user

37 views
Skip to first unread message

rhonda

unread,
Feb 17, 2022, 6:28:42 PMFeb 17
to JsSIP
Hello.

I am trying to figure out how to have a sound played back to the user when they enter a dtmf, so there is audible feedback with each tone sent. Is this something that JsSIP already provides, or would I need to implement playing a sound on the local audio stream with each dtmf send? 

Here is what my call flow looks like from the RTC Session point of view:

07:56:27.519 common.js:113 JsSIP:UA call() +4s
07:56:27.520 common.js:113 JsSIP:RTCSession new +0ms
07:56:27.520 common.js:113 JsSIP:RTCSession connect() +0ms
07:56:27.524 common.js:113 JsSIP:RTCSession emit "peerconnection" +4ms
07:56:27.524 common.js:113 JsSIP:RTCSession newRTCSession() +0ms
07:56:27.590 common.js:113 JsSIP:RTCSession unhold() +66ms
07:56:27.591 common.js:113 JsSIP:RTCSession unmute() +1ms
07:56:27.635 common.js:113 JsSIP:RTCSession session connecting +44ms
07:56:27.635 common.js:113 JsSIP:RTCSession emit "connecting" +0ms
07:56:37.988 common.js:113 JsSIP:RTCSession createLocalDescription()
07:56:38.098 common.js:113 JsSIP:RTCSession emit "sdp"
07:56:38.098 common.js:113 JsSIP:RTCSession emit "sending"  
07:56:38.207 common.js:113 JsSIP:RTCSession receiveInviteResponse()
07:56:38.208 common.js:113 JsSIP:RTCSession receiveInviteResponse() +1ms
07:56:38.208 common.js:113 JsSIP:RTCSession session progress +0ms
07:56:38.208 common.js:113 JsSIP:RTCSession emit "progress" +0ms
07:56:38.221 common.js:113 JsSIP:RTCSession receiveInviteResponse() +13ms
07:56:38.222 common.js:113 JsSIP:Dialog new UAC dialog created with status CONFIRMED +0ms
07:56:38.222 common.js:113 JsSIP:RTCSession emit "sdp" +1ms
07:56:38.224 common.js:113 JsSIP:RTCSession session accepted +2ms
07:56:38.224 common.js:113 JsSIP:RTCSession emit "accepted" +0ms
07:56:38.242 common.js:113 JsSIP:RTCSession sendRequest() +18ms
07:56:38.243 common.js:113 JsSIP:RTCSession session confirmed +1ms
07:56:38.243 common.js:113 JsSIP:RTCSession emit "confirmed" +0ms
07:56:45.038 common.js:113 JsSIP:RTCSession sendDTMF() | tones: 1 +7s

When initiating the call, media constraints are set as such:
phone.call(phoneNumber, {
pcConfig: {
rtcpMuxPolicy: 'negotiate',
},
mediaConstraints: {
audio: true,
video: false,
},
rtcOfferConstraints: {
offerToReceiveAudio: 1,
offerToReceiveVideo: 0,
},

Playing of the remote stream upon receipt of Accepted event:
sipSession.on(RTCSessionEvents.ACCEPTED, () => {
console.log('ACCEPTED', callId);
if (!remoteAudio.current || !remoteStream.current) {
remoteAudio.current = document.createElement('audio');
remoteStream.current = new MediaStream([
sipSession.connection.getReceivers()[0].track,
]);
remoteAudio.current.srcObject = remoteStream.current;
remoteAudio.current
.play()
.catch(() => console.log('ACCEPTED: error playing remote audio'));
}

Igor K

unread,
Mar 9, 2022, 8:19:16 AMMar 9
to JsSIP
You can play DTMF sound using AudioContext
Reply all
Reply to author
Forward
0 new messages