|
@@ -80,6 +80,14 @@ export default function TraceablePeerConnection(
|
80
|
80
|
*/
|
81
|
81
|
this.audioTransferActive = !(options.startSilent === true);
|
82
|
82
|
|
|
83
|
+ /**
|
|
84
|
+ * The DTMF sender instance used to send DTMF tones.
|
|
85
|
+ *
|
|
86
|
+ * @type {RTCDTMFSender|undefined}
|
|
87
|
+ * @private
|
|
88
|
+ */
|
|
89
|
+ this._dtmfSender = undefined;
|
|
90
|
+
|
83
|
91
|
/**
|
84
|
92
|
* Indicates whether or not this peer connection instance is actively
|
85
|
93
|
* sending/receiving video media. When set to <tt>false</tt> the SDP video
|
|
@@ -2053,6 +2061,41 @@ TraceablePeerConnection.prototype.setVideoTransferActive = function(active) {
|
2053
|
2061
|
return changed;
|
2054
|
2062
|
};
|
2055
|
2063
|
|
|
2064
|
+/**
|
|
2065
|
+ * Sends DTMF tones if possible.
|
|
2066
|
+ *
|
|
2067
|
+ * @param {string} tones - The DTMF tones string as defined by {@code RTCDTMFSender.insertDTMF}, 'tones' argument.
|
|
2068
|
+ * @param {number} duration - The amount of time in milliseconds that each DTMF should last. It's 200ms by default.
|
|
2069
|
+ * @param {number} interToneGap - The length of time in miliseconds to wait between tones. It's 200ms by default.
|
|
2070
|
+ *
|
|
2071
|
+ * @returns {void}
|
|
2072
|
+ */
|
|
2073
|
+TraceablePeerConnection.prototype.sendTones = function(tones, duration = 200, interToneGap = 200) {
|
|
2074
|
+ if (!this._dtmfSender) {
|
|
2075
|
+ if (this.peerconnection.getSenders) {
|
|
2076
|
+ const rtpSender = this.peerconnection.getSenders().find(s => s.dtmf);
|
|
2077
|
+
|
|
2078
|
+ this._dtmfSender = rtpSender && rtpSender.dtmf;
|
|
2079
|
+ this._dtmfSender && logger.info(`${this} initialized DTMFSender using getSenders`);
|
|
2080
|
+ }
|
|
2081
|
+
|
|
2082
|
+ if (!this._dtmfSender) {
|
|
2083
|
+ const localAudioTrack = Array.from(this.localTracks.values()).find(t => t.isAudioTrack());
|
|
2084
|
+
|
|
2085
|
+ if (this.peerconnection.createDTMFSender && localAudioTrack) {
|
|
2086
|
+ this._dtmfSender = this.peerconnection.createDTMFSender(localAudioTrack.getTrack());
|
|
2087
|
+ }
|
|
2088
|
+ this._dtmfSender && logger.info(`${this} initialized DTMFSender using deprecated createDTMFSender`);
|
|
2089
|
+ }
|
|
2090
|
+ }
|
|
2091
|
+
|
|
2092
|
+ if (this._dtmfSender) {
|
|
2093
|
+ this._dtmfSender.insertDTMF(tones, duration, interToneGap);
|
|
2094
|
+ } else {
|
|
2095
|
+ logger.warn(`${this} sendTones - failed to select DTMFSender`);
|
|
2096
|
+ }
|
|
2097
|
+};
|
|
2098
|
+
|
2056
|
2099
|
/**
|
2057
|
2100
|
* Makes the underlying TraceablePeerConnection generate new SSRC for
|
2058
|
2101
|
* the recvonly video stream.
|