mirror of
https://github.com/jambonz/jambonz-feature-server.git
synced 2025-12-20 08:40:38 +00:00
update pause/resume ongoing transcribe task if re-invite for hold and unhold is received
This commit is contained in:
@@ -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,40 @@ class CallSession extends Emitter {
|
||||
listenTask.updateListen(opts.listen_status);
|
||||
}
|
||||
|
||||
// Jambonz only update transcribe task when receive RE-INVITE:
|
||||
// 1. Pause transcribe task if it's running and hold RE-INVITE is received
|
||||
// 2. Resume transcribe task if it 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 opts = {
|
||||
transcribe_status: isHold ? TranscribeStatus.Pause : TranscribeStatus.Resume
|
||||
};
|
||||
transcribeTasks.forEach((t) => {
|
||||
if (isHold && !t.paused) {
|
||||
t.updateTranscribe(opts);
|
||||
t.pausedByHold = true;
|
||||
} else if (!isHold && t.pausedByHold) {
|
||||
if (t.paused) {
|
||||
t.updateTranscribe(opts);
|
||||
}
|
||||
t.pausedByHold = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* perform live call control -- change Transcribe status
|
||||
* @param {object} opts
|
||||
@@ -2241,6 +2277,13 @@ Duration=${duration} `
|
||||
this.logger.info('got reINVITE but no endpoint and media has not been released');
|
||||
res.send(488);
|
||||
}
|
||||
|
||||
// if there
|
||||
const opts = {
|
||||
transcribe_status: isOnhold(req.body) ? TranscribeStatus.Pause : TranscribeStatus.Resume
|
||||
};
|
||||
this.logger.info('Transcribe is');
|
||||
this._lccTranscribeStatus(opts);
|
||||
} catch (err) {
|
||||
this.logger.error(err, 'Error handling reinvite');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user