mirror of
https://github.com/jambonz/jambonz-feature-server.git
synced 2025-12-20 08:40:38 +00:00
add support for recording conference to a file
This commit is contained in:
@@ -5,11 +5,14 @@ const {TaskName, TaskPreconditions, BONG_TONE} = require('../utils/constants');
|
||||
const normalizeJambones = require('../utils/normalize-jambones');
|
||||
const makeTask = require('./make_task');
|
||||
const bent = require('bent');
|
||||
const fs = require('fs');
|
||||
const fsPromises = require('fs/promises');
|
||||
const assert = require('assert');
|
||||
const WAIT = 'wait';
|
||||
const JOIN = 'join';
|
||||
const START = 'start';
|
||||
|
||||
|
||||
function confNoMatch(str) {
|
||||
return str.match(/^No active conferences/) || str.match(/Conference.*not found/);
|
||||
}
|
||||
@@ -49,7 +52,7 @@ class Conference extends Task {
|
||||
'beep', 'startConferenceOnEnter', 'endConferenceOnExit', 'joinMuted',
|
||||
'maxParticipants', 'waitHook', 'statusHook', 'endHook', 'enterHook'
|
||||
].forEach((attr) => this[attr] = this.data[attr]);
|
||||
|
||||
this.record = this.data.record || {};
|
||||
this.statusEvents = [];
|
||||
if (this.statusHook) {
|
||||
['start', 'end', 'join', 'leave', 'start-talking', 'stop-talking'].forEach((e) => {
|
||||
@@ -68,6 +71,9 @@ class Conference extends Task {
|
||||
|
||||
get name() { return TaskName.Conference; }
|
||||
|
||||
get shouldRecord() { return this.record.path; }
|
||||
get isRecording() { return this.recordingInProgress; }
|
||||
|
||||
async exec(cs, ep) {
|
||||
await super.exec(cs);
|
||||
this.ep = ep;
|
||||
@@ -100,7 +106,7 @@ class Conference extends Task {
|
||||
this.logger.info(err, `TaskConference:exec - error in conference ${this.confName}`);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
async kill(cs) {
|
||||
super.kill(cs);
|
||||
this.logger.info(`Conference:kill ${this.confName}`);
|
||||
@@ -346,6 +352,16 @@ class Conference extends Task {
|
||||
if (response.body && /\d+/.test(response.body)) this.participantCount = parseInt(response.body);
|
||||
this._notifyConferenceEvent(cs, 'join');
|
||||
|
||||
// start recording if requested and we just started the conference
|
||||
if (startConf && this.shouldRecord) {
|
||||
this.logger.info(`recording conference to ${this.record.path}`);
|
||||
try {
|
||||
await this.ep.api(`conference ${this.confName} record ${this.record.path}`);
|
||||
} catch (err) {
|
||||
this.logger.info({err}, 'Conference:_joinConference - failed to start recording');
|
||||
}
|
||||
}
|
||||
|
||||
// listen for conference events
|
||||
this.ep.filter('Conference-Unique-ID', this.confUuid);
|
||||
this.ep.conn.on('esl::event::CUSTOM::*', this.__onConferenceEvent.bind(this, cs)) ;
|
||||
|
||||
Reference in New Issue
Block a user