mirror of
https://github.com/jambonz/sbc-outbound.git
synced 2026-07-04 19:32:04 +00:00
factor out rtpengine into package
This commit is contained in:
+13
-9
@@ -1,6 +1,5 @@
|
||||
const Emitter = require('events');
|
||||
const Client = require('rtpengine-client').Client ;
|
||||
const rtpengine = new Client();
|
||||
const {getRtpEngine} = require('jambonz-rtpengine-utils')(process.env.JAMBONES_RTPENGINES.split(','));
|
||||
const {makeRtpEngineOpts} = require('./utils');
|
||||
const {forwardInDialogRequests} = require('drachtio-fn-b2b-sugar');
|
||||
const {SipError} = require('drachtio-srf');
|
||||
@@ -15,17 +14,22 @@ class CallSession extends Emitter {
|
||||
this.performLcr = this.srf.locals.dbHelpers.performLcr;
|
||||
this.logger = logger.child({callId: req.get('Call-ID')});
|
||||
this.useWss = req.locals.registration && req.locals.registration.protocol === 'wss';
|
||||
|
||||
// TODO: we always using the first rtpengine here
|
||||
// we should be load balancing, and doing some form of health checking
|
||||
this.offer = rtpengine.offer.bind(rtpengine, this.srf.locals.rtpEngines[0]);
|
||||
this.answer = rtpengine.answer.bind(rtpengine, this.srf.locals.rtpEngines[0]);
|
||||
this.del = rtpengine.delete.bind(rtpengine, this.srf.locals.rtpEngines[0]);
|
||||
}
|
||||
|
||||
async connect() {
|
||||
const engine = getRtpEngine(this.logger);
|
||||
if (!engine) {
|
||||
this.logger.info('No available rtpengines, rejecting call!');
|
||||
return this.res.send(480);
|
||||
}
|
||||
debug(`got engine: ${JSON.stringify(engine)}`);
|
||||
const {offer, answer, del} = engine;
|
||||
this.offer = offer;
|
||||
this.answer = answer;
|
||||
this.del = del;
|
||||
|
||||
this.rtpEngineOpts = makeRtpEngineOpts(this.req, false, this.useWss);
|
||||
this.rtpEngineResource = {destroy: this.del.bind(rtpengine, this.rtpEngineOpts.common)};
|
||||
this.rtpEngineResource = {destroy: this.del.bind(null, this.rtpEngineOpts.common)};
|
||||
let proxy, uris;
|
||||
|
||||
try {
|
||||
|
||||
Generated
+20
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "sbc-outbound",
|
||||
"version": "0.3.1",
|
||||
"version": "0.3.2",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
@@ -1818,6 +1818,25 @@
|
||||
"redis": "^2.8.0"
|
||||
}
|
||||
},
|
||||
"jambonz-rtpengine-utils": {
|
||||
"version": "0.0.5",
|
||||
"resolved": "https://registry.npmjs.org/jambonz-rtpengine-utils/-/jambonz-rtpengine-utils-0.0.5.tgz",
|
||||
"integrity": "sha512-tkAwXkV6nYVBvF/epcIoNOUX8NDepFo25WP4a2DBu0+g8e76MzDChXGuziYRGswL3TFZxd6faTbU44rg+UcoMA==",
|
||||
"requires": {
|
||||
"debug": "^4.1.1",
|
||||
"rtpengine-client": "0.0.9"
|
||||
},
|
||||
"dependencies": {
|
||||
"rtpengine-client": {
|
||||
"version": "0.0.9",
|
||||
"resolved": "https://registry.npmjs.org/rtpengine-client/-/rtpengine-client-0.0.9.tgz",
|
||||
"integrity": "sha512-AkeDx6QEk/WtIBGnoxf3/lWbV0h4JTlPPBCHW+qjYT4xfKYzzCFCmP639ovuIJhE0L6aL89Vv0YmlQdEWo6ofw==",
|
||||
"requires": {
|
||||
"bencode": "^1.0.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"js-tokens": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz",
|
||||
|
||||
+2
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "sbc-outbound",
|
||||
"version": "0.3.1",
|
||||
"version": "0.3.2",
|
||||
"main": "app.js",
|
||||
"engines": {
|
||||
"node": ">= 8.10.0"
|
||||
@@ -30,6 +30,7 @@
|
||||
"debug": "^4.1.1",
|
||||
"drachtio-fn-b2b-sugar": "^0.0.12",
|
||||
"drachtio-srf": "^4.4.28",
|
||||
"jambonz-rtpengine-utils": "0.0.5",
|
||||
"jambonz-db-helpers": "^0.3.2",
|
||||
"jambonz-mw-registrar": "^0.1.0",
|
||||
"pino": "^5.14.0",
|
||||
|
||||
Reference in New Issue
Block a user