mirror of
https://github.com/jambonz/jambonz-feature-server.git
synced 2025-12-18 20:07:44 +00:00
sending DTMF inband from updateCall/command (#536)
* sending DTMF inband from updateCall/command * wip * wip
This commit is contained in:
0
bin/k8s-pre-stop-hook.js
Executable file → Normal file
0
bin/k8s-pre-stop-hook.js
Executable file → Normal file
@@ -1187,6 +1187,38 @@ class CallSession extends Emitter {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* perform live call control - send RFC 2833 DTMF
|
||||
* @param {obj} opts
|
||||
* @param {string} opts.dtmf.digit - DTMF digit
|
||||
* @param {string} opts.dtmf.duration - Optional, Duration
|
||||
*/
|
||||
async _lccDtmf(opts, callSid) {
|
||||
const {dtmf} = opts;
|
||||
const {digit, duration = 250} = dtmf;
|
||||
if (!this.hasStableDialog) {
|
||||
this.logger.info('CallSession:_lccDtmf - invalid command as we do not have a stable call');
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const dlg = callSid === this.callSid ? this.dlg : this.currentTask.dlg;
|
||||
const res = await dlg.request({
|
||||
method: 'INFO',
|
||||
headers: {
|
||||
'Content-Type': 'application/dtmf',
|
||||
'X-Reason': 'Dtmf'
|
||||
},
|
||||
body: `Signal=${digit}
|
||||
Duration=${duration} `
|
||||
});
|
||||
this.logger.debug({res}, `CallSession:_lccDtmf
|
||||
got response to INFO DTMF digit=${digit} and duration=${duration}`);
|
||||
return res;
|
||||
} catch (err) {
|
||||
this.logger.error({err}, 'CallSession:_lccDtmf - error sending INFO RFC 2833 DTMF');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* perform live call control -- whisper to one party or the other on a call
|
||||
* @param {array} opts - array of play or say tasks
|
||||
@@ -1270,6 +1302,8 @@ class CallSession extends Emitter {
|
||||
else if (opts.sip_request) {
|
||||
const res = await this._lccSipRequest(opts, callSid);
|
||||
return {status: res.status, reason: res.reason};
|
||||
} else if (opts.dtmf) {
|
||||
await this._lccDtmf(opts, callSid);
|
||||
}
|
||||
else if (opts.record) {
|
||||
await this.notifyRecordOptions(opts.record);
|
||||
@@ -1452,6 +1486,13 @@ class CallSession extends Emitter {
|
||||
});
|
||||
break;
|
||||
|
||||
case 'dtmf':
|
||||
this._lccDtmf(data, call_sid)
|
||||
.catch((err) => {
|
||||
this.logger.info({err, data}, `CallSession:_onCommand - error sending RFC 2833 DTMF ${data}`);
|
||||
});
|
||||
break;
|
||||
|
||||
default:
|
||||
this.logger.info(`CallSession:_onCommand - invalid command ${command}`);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user