mirror of
https://github.com/jambonz/jambonz-feature-server.git
synced 2025-12-20 08:40:38 +00:00
wip (#979)
This commit is contained in:
@@ -2,6 +2,7 @@ const Emitter = require('events');
|
||||
const fs = require('fs');
|
||||
const {
|
||||
CallDirection,
|
||||
MediaPath,
|
||||
TaskPreconditions,
|
||||
CallStatus,
|
||||
TaskName,
|
||||
@@ -1589,6 +1590,15 @@ Duration=${duration} `
|
||||
this.logger.info({response}, '_lccBoostAudioSignal: response from freeswitch');
|
||||
}
|
||||
|
||||
async _lccMediaPath(desiredPath) {
|
||||
const task = this.currentTask;
|
||||
if (!task || task.name !== TaskName.Dial) {
|
||||
return this.logger.info('CallSession:_lccMediaPath - invalid command since we are not in a dial verb');
|
||||
}
|
||||
task.updateMediaPath(desiredPath)
|
||||
.catch((err) => this.logger.error(err, 'CallSession:_lccMediaPath'));
|
||||
}
|
||||
|
||||
_lccToolOutput(tool_call_id, opts, callSid) {
|
||||
// only valid if we are in an LLM verb
|
||||
const task = this.currentTask;
|
||||
@@ -1672,6 +1682,9 @@ Duration=${duration} `
|
||||
else if (opts.boostAudioSignal) {
|
||||
return this._lccBoostAudioSignal(opts, callSid);
|
||||
}
|
||||
else if (opts.media_path) {
|
||||
return this._lccMediaPath(opts.media_path, callSid);
|
||||
}
|
||||
else if (opts.llm_tool_output) {
|
||||
return this._lccToolOutput(opts.tool_call_id, opts.llm_tool_output, callSid);
|
||||
}
|
||||
@@ -1975,6 +1988,13 @@ Duration=${duration} `
|
||||
});
|
||||
break;
|
||||
|
||||
case 'media:path':
|
||||
this._lccMediaPath(data, call_sid)
|
||||
.catch((err) => {
|
||||
this.logger.info({err, data}, 'CallSession:_onCommand - error setting media path');
|
||||
});
|
||||
break;
|
||||
|
||||
case 'llm:tool-output':
|
||||
this._lccToolOutput(tool_call_id, data, call_sid);
|
||||
break;
|
||||
@@ -2505,27 +2525,35 @@ Duration=${duration} `
|
||||
};
|
||||
}
|
||||
|
||||
async releaseMediaToSBC(remoteSdp) {
|
||||
async releaseMediaToSBC(remoteSdp, releaseMediaEntirely) {
|
||||
assert(this.dlg && this.dlg.connected && this.ep && typeof remoteSdp === 'string');
|
||||
await this.dlg.modify(remoteSdp, {
|
||||
headers: {
|
||||
'X-Reason': 'release-media'
|
||||
'X-Reason': releaseMediaEntirely ? 'release-media-entirely' : 'release-media'
|
||||
}
|
||||
});
|
||||
this.ep.destroy()
|
||||
.then(() => this.ep = null)
|
||||
.catch((err) => this.logger.error({err}, 'CallSession:releaseMediaToSBC: Error destroying endpoint'));
|
||||
try {
|
||||
await this.ep.destroy();
|
||||
} catch (err) {
|
||||
this.logger.error({err}, 'CallSession:releaseMediaToSBC: Error destroying endpoint');
|
||||
}
|
||||
this.ep = null;
|
||||
}
|
||||
|
||||
async reAnchorMedia() {
|
||||
async reAnchorMedia(currentMediaRoute = MediaPath.PartialMedia) {
|
||||
assert(this.dlg && this.dlg.connected && !this.ep);
|
||||
|
||||
this.ep = await this.ms.createEndpoint({remoteSdp: this.dlg.remote.sdp});
|
||||
this._configMsEndpoint();
|
||||
await this.dlg.modify(this.ep.local.sdp, {
|
||||
headers: {
|
||||
'X-Reason': 'anchor-media'
|
||||
}
|
||||
});
|
||||
this._configMsEndpoint();
|
||||
|
||||
if (currentMediaRoute === MediaPath.NoMedia) {
|
||||
await this.ep.modify(this.dlg.remote.sdp);
|
||||
}
|
||||
}
|
||||
|
||||
async handleReinviteAfterMediaReleased(req, res) {
|
||||
|
||||
Reference in New Issue
Block a user