Share via


insertDTMF method

[Some information relates to pre-released product which may be substantially modified before it's commercially released. Microsoft makes no warranties, express or implied, with respect to the information provided here.]

Used to send DTMF tones.

Since DTMF tones cannot be sent without configuring the DTMF codec, if insertDTMF() is called prior to sender.send(parameters), or if sender.send(parameters) was called but parameters did not include the DTMF codec, throw an InvalidStateError exception.

The tones parameter is treated as a series of characters. The characters 0 through 9, A through D, #, and * generate the associated DTMF tones. The characters a to d are equivalent to A to D. The character ',' indicates a delay of 2 seconds before processing the next character in the tones parameter. All other characters MUST be considered unrecognized.

The duration parameter indicates the duration in ms to use for each character passed in the tones parameters. The duration cannot be more than 6000 ms or less than 40 ms. The default duration is 100 ms for each tone.

The interToneGap parameter indicates the gap between tones. It MUST be at least 30 ms. The default value is 70 ms.

The browser MAY increase the duration and interToneGap times to cause the times that DTMF start and stop to align with the boundaries of RTP packets but it MUST not increase either of them by more than the duration of a single RTP audio packet.

When the insertDTMF() method is invoked, the user agent MUST run the following steps:

1. Set the object's toneBuffer attribute to the value of the first argument, the duration attribute to the value of the second argument, and the interToneGap attribute to the value of the third argument.

2. If toneBuffer contains any unrecognized characters, throw an InvalidCharacterError exception and abort these steps.

3. If toneBuffer is an empty string, return.

4. If the value of the duration attribute is less than 40, set it to 40. If, on the other hand, the value is greater than 6000, set it to 6000.

5. If the value of the interToneGap attribute is less than 30, set it to 30.

6. If a Playout task is scheduled to be run; abort these steps; otherwise queue a task that runs the following steps (Playout task):

1. If toneBuffer is an empty string, fire an event named tonechange with an empty string at the RTCDtmfSender object and abort these steps.

2. Remove the first character from toneBuffer and let that character be tone.

3. Start playout of tone for duration ms on the associated RTP media stream, using the appropriate codec.

4. Queue a task to be executed in duration + interToneGap ms from now that runs the steps labeled Playout task.

5. Fire an event named tonechange with a string consisting of tone at the RTCDtmfSender object.

Calling insertDTMF() with an empty tones parameter can be used to cancel all tones queued to play after the currently playing tone.

Syntax

var retval = RTCDtmfSender.insertDTMF(tones, duration, interToneGap);

Parameters

  • tones
    Type: DOMString

  • duration [optional]
    Type: long

  • interToneGap [optional]
    Type: long

Return value

This method does not return a value.

Standards information

See also

RTCDtmfSender