Est’s Blog

Original link: https://blog.est.im/2022/stdout-10

When playing with WebRTC, I found that it actually supports DTMF dial tone built-in. So I got interested and wanted to make a demo to play with

After writing for a long time, the debugging fails, and an error is reported

VM987:1 Uncaught DOMException: Failed to execute ‘insertDTMF’ on ‘RTCDTMFSender’: The ‘canInsertDTMF’ attribute is false: this sender cannot send DTMF.

After carefully studying this thing , it turns out that WebRTC does not transmit audio directly, but sends a control signal, and the receiver plays the audio, so you need to create a real duplex RTC locally and open the microphone permission to play DTMF audio.

WebRTC doesn’t send DTMF codes as audio data. Instead, they’re sent out-of-band, as RTP payloads. Note, however, that although it’s possible to send DTMF using WebRTC, there is currently no way to detect or receive incoming DTMF. WebRTC currently ignores these payloads;

This goes far. So I used AudioContext() to paste it again. A total of less than 1000 bytes.

https://lab.est.im/dtmf source code

Um. It’s pretty simple. In particular, the oscillator has a .stop(0.2) parameter to avoid the trouble of setTimeout . There are many tutorials online that are quite complicated.

Btw hang some old scripts under the lab domain name.

Btw2 changed the RSS to full text output.

This article is reproduced from: https://blog.est.im/2022/stdout-10
This site is for inclusion only, and the copyright belongs to the original author.