Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
davehorton committed Jun 15, 2018
1 parent 8eea7c6 commit aa00e37
Show file tree
Hide file tree
Showing 12 changed files with 751 additions and 464 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -38,3 +38,5 @@ jspm_packages

# Optional REPL history
.node_repl_history

.eslint*
6 changes: 3 additions & 3 deletions README.md
@@ -1,10 +1,10 @@
# drachtio-rtpengine-webrtcproxy

Open-source webrtc proxy server built using [drachtio](https://github.com/davehorton/drachtio-server) (SIP Proxy) and [rtpengine](https://github.com/sipwise/rtpengine) (RTP proxy).
Open-source webrtc proxy server built using [drachtio](https://drachtio.org) and [rtpengine](https://github.com/sipwise/rtpengine).

## Installation

As mentioned above, the following are pre-requisites and should be installed first:
As mentioned above, the following are pre-requisites and should be installed somewhere in your network:

* [drachtio](https://github.com/davehorton/drachtio-server)
* [rtpengine](https://github.com/sipwise/rtpengine)
Expand All @@ -19,7 +19,7 @@ $ cd drachtio-rtpengine-webrtcproxy
$ npm install
```

Next, copy <code>config.json.example</code> to <code>config.json</code>, and edit to specify the coordinates of your drachtio server and rtpengine processes.
Next, modify<code>config/default.json</code> as needed.

Then fire it up!

Expand Down
65 changes: 23 additions & 42 deletions app.js
@@ -1,45 +1,26 @@
'use strict';

const drachtio = require('drachtio') ;
const app = drachtio() ;
const Srf = require('drachtio-srf') ;
const srf = new Srf(app) ;
const Register = require('./lib/register') ;
const Registrar = require('./lib/registrar') ;
const Subscriber = require('./lib/subscriber') ;
const CallProcessor = require('./lib/call-processor') ;
const registrar = new Registrar() ;
const register = new Register() ;
const subscriber = new Subscriber() ;
const callProcessor = new CallProcessor() ;
const Rtpengine = require('./lib/rtpengine') ;
const config = require('./config') ;
const rtpengine = new Rtpengine( config.rtpengine['ng-address'], config.rtpengine['ng-port'], config.rtpengine['local-address'], config.rtpengine['local-port']) ;
//const debug = require('debug')('drachtio-rtpengine-webrtcproxy') ;

srf.connect(config.drachtio)
.on('connect', function(err, hostport) {
console.log('connected to drachtio listening for SIP on %s', hostport) ;
})
.on('error', function(err){
console.error('Error connecting to drachtio server: ', err.message ) ;
})
.on('reconnecting', function(opts) {
console.error('attempting to reconect: ', opts) ;
}) ;

const srf = new Srf() ;
const logger = require('pino')();
const Register = require('./lib/register');
const Registrar = require('./lib/registrar');
const Subscriber = require('./lib/subscriber');
const CallProcessor = require('./lib/call-processor');
const registrar = new Registrar(logger) ;
const register = new Register(logger) ;
const subscriber = new Subscriber(logger) ;
const callProcessor = new CallProcessor(logger) ;
const config = require('config') ;
const Client = require('rtpengine-client').Client ;
const rtpengine = new Client(config.get('rtpengine.local-port'));

register.start(srf, registrar) ;
subscriber.start(srf, registrar) ;
callProcessor.start( srf, rtpengine, registrar ) ;
srf.connect(config.get('drachtio'))
.on('connect', (err, hostport) => {
console.log(`connected to drachtio listening for SIP on hostport ${hostport}`) ;
})
.on('error', (err) => {
console.error(`Error connecting to drachtio server: ${err.message}`) ;
});

/*
rtpengine.on('listening', function() {
rtpengine.ping( (err, response) => {
if( err ) {
console.error(`error sending ping: ${JSON.stringify(err)}`);
}
debug(`ping result: ${response.result}`);
}) ;
}) ;
*/
register.start(srf, registrar);
subscriber.start(srf, registrar);
callProcessor.start(srf, rtpengine, registrar);
12 changes: 0 additions & 12 deletions config.json.example

This file was deleted.

12 changes: 12 additions & 0 deletions config/default.json
@@ -0,0 +1,12 @@
{
"drachtio": {
"host": "127.0.0.1",
"port": 9022,
"secret": "cymru"
},
"rtpengine": {
"host": "127.0.0.1",
"port": 2222222,
"local-port": 2223
}
}

0 comments on commit aa00e37

Please sign in to comment.