mirror of
https://github.com/jambonz/jambonz-feature-server.git
synced 2026-01-25 02:07:56 +00:00
Compare commits
4 Commits
feat/speec
...
fix/google
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
af7a989aef | ||
|
|
208f61e375 | ||
|
|
d473031bdc | ||
|
|
54a60e26ce |
@@ -8,7 +8,8 @@ const {
|
||||
KillReason,
|
||||
RecordState,
|
||||
AllowedSipRecVerbs,
|
||||
AllowedConfirmSessionVerbs
|
||||
AllowedConfirmSessionVerbs,
|
||||
TranscribeStatus
|
||||
} = require('../utils/constants');
|
||||
const moment = require('moment');
|
||||
const assert = require('assert');
|
||||
@@ -29,6 +30,7 @@ const {
|
||||
} = require('../config');
|
||||
const bent = require('bent');
|
||||
const BackgroundTaskManager = require('../utils/background-task-manager');
|
||||
const { isOnhold } = require('../utils/sdp-utils');
|
||||
const BADPRECONDITIONS = 'preconditions not met';
|
||||
const CALLER_CANCELLED_ERR_MSG = 'Response not sent due to unknown transaction';
|
||||
|
||||
@@ -1336,6 +1338,39 @@ class CallSession extends Emitter {
|
||||
listenTask.updateListen(opts.listen_status);
|
||||
}
|
||||
|
||||
// Jambonz only update transcribe task when it's received RE-INVITE:
|
||||
// 1. Pause transcribe task if the task is running and hold RE-INVITE is received
|
||||
// 2. Resume transcribe task if the task was paused by jambonz due to hold and unhold RE-INVITE is received
|
||||
async pauseOrResumeTranscribeTaskByReInvite(req) {
|
||||
const task = this.currentTask;
|
||||
const transcribeTasks = [];
|
||||
// Gather running transcribe tasks
|
||||
if (this.backgroundTaskManager.isTaskRunning('transcribe')) {
|
||||
transcribeTasks.push(this.backgroundTaskManager.getTask('transcribe'));
|
||||
}
|
||||
|
||||
// Include current task if it is transcribe-related
|
||||
if (task && [TaskName.Dial, TaskName.Transcribe].includes(task.name)) {
|
||||
const transcribeTask = task.name === TaskName.Transcribe ? task : task.transcribeTask;
|
||||
if (transcribeTask) transcribeTasks.push(transcribeTask);
|
||||
}
|
||||
|
||||
const isHold = isOnhold(req.body);
|
||||
const transcribe_status = isHold ? TranscribeStatus.Pause : TranscribeStatus.Resume;
|
||||
this.logger.debug(`updating transcribe_status for ${transcribeTasks.length} transcribe tasks.`);
|
||||
transcribeTasks.forEach((t) => {
|
||||
if (isHold && !t.paused) {
|
||||
t.updateTranscribe(transcribe_status);
|
||||
t.pausedByHold = true;
|
||||
} else if (!isHold && t.pausedByHold) {
|
||||
if (t.paused) {
|
||||
t.updateTranscribe(transcribe_status);
|
||||
}
|
||||
t.pausedByHold = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* perform live call control -- change Transcribe status
|
||||
* @param {object} opts
|
||||
@@ -2241,6 +2276,8 @@ Duration=${duration} `
|
||||
this.logger.info('got reINVITE but no endpoint and media has not been released');
|
||||
res.send(488);
|
||||
}
|
||||
|
||||
await this.pauseOrResumeTranscribeTaskByReInvite(req);
|
||||
} catch (err) {
|
||||
this.logger.error(err, 'Error handling reinvite');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user