mirror of
https://github.com/jambonz/sbc-inbound.git
synced 2026-10-09 21:14:09 +00:00
add support for multiple rtpengines
This commit is contained in:
+12
-9
@@ -1,6 +1,4 @@
|
||||
const Emitter = require('events');
|
||||
const Client = require('rtpengine-client').Client ;
|
||||
const rtpengine = new Client();
|
||||
const {getAppserver, isWSS, makeRtpEngineOpts} = require('./utils');
|
||||
const {forwardInDialogRequests} = require('drachtio-fn-b2b-sugar');
|
||||
const {parseUri, SipError} = require('drachtio-srf');
|
||||
@@ -13,17 +11,22 @@ class CallSession extends Emitter {
|
||||
this.res = res;
|
||||
this.srf = req.srf;
|
||||
this.logger = logger.child({callId: req.get('Call-ID')});
|
||||
|
||||
// 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 getRtpEngine = require('./rtpengine')(this.logger);
|
||||
const engine = getRtpEngine();
|
||||
if (!engine) {
|
||||
this.logger.info('No available rtpengines, rejecting call!');
|
||||
return this.res.send(480);
|
||||
}
|
||||
const {offer, answer, del} = engine;
|
||||
this.offer = offer;
|
||||
this.answer = answer;
|
||||
this.del = del;
|
||||
|
||||
this.rtpEngineOpts = makeRtpEngineOpts(this.req, isWSS(this.req), false);
|
||||
this.rtpEngineResource = {destroy: this.del.bind(rtpengine, this.rtpEngineOpts.common)};
|
||||
this.rtpEngineResource = {destroy: this.del.bind(null, this.rtpEngineOpts.common)};
|
||||
const obj = parseUri(this.req.uri);
|
||||
const appServer = getAppserver(this.srf);
|
||||
let proxy, host, uri;
|
||||
|
||||
Reference in New Issue
Block a user