CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-webrtc-adapter

A shim to insulate apps from WebRTC spec changes and browser prefix differences

Overall
score

98%

Overview
Eval results
Files

task.mdevals/scenario-8/

DTMF Tone Sender for WebRTC Voice Calls

Build a WebRTC voice call application component that sends DTMF (touch-tone) signals over an active peer connection. The component should enable sending phone keypad tones (0-9, *, #, A-D) during a voice call, similar to what happens when you press buttons on a phone keypad during a call.

Requirements

Your implementation should:

  1. Create an RTCPeerConnection with audio capabilities
  2. Add an audio track to the peer connection
  3. Provide functionality to send DTMF tones through the active audio connection
  4. Handle the DTMF sender lifecycle properly (checking availability, managing state)
  5. Support sending single tones and tone sequences with appropriate timing

Functionality

Basic DTMF Sending

  • Send a single DTMF tone ('5') through an active audio connection @test
  • Send a sequence of DTMF tones ('123') with 100ms duration per tone @test

DTMF Availability

  • Attempting to access DTMF functionality on a sender without an audio track returns null @test
  • DTMF sender is available when an audio track is present @test

Tone Parameters

  • Send DTMF tones with custom duration (200ms) and inter-tone gap (50ms) @test
  • Send special DTMF characters ('*', '#') successfully @test

Implementation

@generates

API

/**
 * Creates a DTMF sender component for WebRTC voice calls
 *
 * @param {RTCPeerConnection} peerConnection - The RTCPeerConnection to use
 * @returns {Object} An object with methods to manage DTMF sending
 */
function createDTMFSender(peerConnection) {
  // IMPLEMENTATION HERE
}

/**
 * Adds an audio track to the peer connection and prepares for DTMF
 *
 * @param {MediaStreamTrack} audioTrack - The audio track to add
 * @returns {RTCRtpSender} The RTP sender for the audio track
 */
function addAudioTrack(audioTrack) {
  // IMPLEMENTATION HERE
}

/**
 * Gets the DTMF sender for the audio track
 *
 * @returns {RTCDTMFSender|null} The DTMF sender or null if unavailable
 */
function getDTMFSender() {
  // IMPLEMENTATION HERE
}

/**
 * Sends DTMF tones with specified timing
 *
 * @param {string} tones - The DTMF tones to send (e.g., "123", "*", "#")
 * @param {number} duration - Duration of each tone in milliseconds (default: 100)
 * @param {number} interToneGap - Gap between tones in milliseconds (default: 70)
 * @returns {boolean} True if tones were queued successfully
 */
function sendTones(tones, duration = 100, interToneGap = 70) {
  // IMPLEMENTATION HERE
}

module.exports = {
  createDTMFSender,
  addAudioTrack,
  getDTMFSender,
  sendTones
};

Dependencies { .dependencies }

webrtc-adapter { .dependency }

Provides cross-browser WebRTC compatibility, including DTMF sender support for audio tracks.

@satisfied-by

Install with Tessl CLI

npx tessl i tessl/npm-webrtc-adapter

tile.json