All Projects → drachtio → drachtio-siprec-recording-server

drachtio / drachtio-siprec-recording-server

Licence: MIT license
SIPREC recording server based on drachtio and rtpengine

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to drachtio-siprec-recording-server

Heplify Server
HEP Capture Server
Stars: ✭ 110 (+89.66%)
Mutual labels:  sip
Webrtc To Sip
Setup for a WEBRTC client and Kamailio server to call SIP clients
Stars: ✭ 173 (+198.28%)
Mutual labels:  sip
Restcomm Connect
The Open Source Cloud Communications Platform
Stars: ✭ 232 (+300%)
Mutual labels:  sip
Sippts
Set of tools to audit SIP based VoIP Systems
Stars: ✭ 116 (+100%)
Mutual labels:  sip
Stun
A Go implementation of STUN
Stars: ✭ 141 (+143.1%)
Mutual labels:  sip
Sipp Scenarios
SIPp scenarios I use for testing SIP stuff
Stars: ✭ 190 (+227.59%)
Mutual labels:  sip
Kamailio
Kamailio - The Open Source SIP Server for large VoIP and real-time communication platforms -
Stars: ✭ 1,358 (+2241.38%)
Mutual labels:  sip
opentok-rtc
OpenTok demo application
Stars: ✭ 97 (+67.24%)
Mutual labels:  sip
Tg2sip
Telegram <-> SIP voice gateway
Stars: ✭ 142 (+144.83%)
Mutual labels:  sip
React Native Pjsip
A PJSIP module for React Native.
Stars: ✭ 229 (+294.83%)
Mutual labels:  sip
Ivozprovider
IVOZ Provider - Multitenant solution for VoIP telephony providers
Stars: ✭ 127 (+118.97%)
Mutual labels:  sip
Restcomm Android Sdk
Android Mobile SDK to easily integrate communication features (WebRTC, messaging, presence, voice, video, screensharing) based on RestComm into native Mobile Applications
Stars: ✭ 139 (+139.66%)
Mutual labels:  sip
Linphone Desktop
Linphone is a free VoIP and video softphone based on the SIP protocol. Mirror of git://git.linphone.org/linphone-desktop.git
Stars: ✭ 212 (+265.52%)
Mutual labels:  sip
Captagent
100% Open-Source Packet Capture Agent for HEP
Stars: ✭ 116 (+100%)
Mutual labels:  sip
sippet
C++ SIP stack based on Chromium source code
Stars: ✭ 23 (-60.34%)
Mutual labels:  sip
Media Server
RTSP/RTP/RTMP/FLV/HLS/MPEG-TS/MPEG-PS/MPEG-DASH/MP4/fMP4/MKV/WebM
Stars: ✭ 1,363 (+2250%)
Mutual labels:  sip
Flutter Webrtc
WebRTC plugin for Flutter Mobile/Desktop/Web
Stars: ✭ 2,764 (+4665.52%)
Mutual labels:  sip
OBS Settings Manager
Backup your OBS Studio profiles and manage them in an easy, user friendly way.
Stars: ✭ 20 (-65.52%)
Mutual labels:  recording
tSIP
SIP softphone
Stars: ✭ 103 (+77.59%)
Mutual labels:  sip
Siprtcproxy
网关服务:Sip与Rtc互通,实现Web,Android,iOS,小程序,SIP座机,PSTN电话,手机互通。
Stars: ✭ 217 (+274.14%)
Mutual labels:  sip

drachtio-siprec-recording-server Build Status

An open source implementation of a SIPREC recording server based on dractio and using either

Install

This application requires a drachtio SIP server to be installed in your network. Please refer to the build and installation instructions here, or here.

  • Copy either config/default.json.example-rtpengine or config/default.json.example-freeswitch depending on which back-end media server you want to use (it is an either-or choice: you can't mix them) to config/local.json and edit to provide the IP addresses/ports for your configuration (i.e., location of the drachtio server, and either the rtpengine or freeswitch/asterisk media server).
  • Run npm install
  • Run node app to run.
  • Configure your SBC to send SIPREC invites to your drachtio server.

Using rtpengine as the media server

When using rtpengine as the recorder, there is minimal configuration you will need to do on the rtpengine server -- a vanilla install will do. The application will use the ng control protocol, so you will need to open the UDP port on the rtpengine server to allow commands from the server running the drachtio-siprec-recording-server application.

Also, rtpengine generates recordings in pcap file format, so you will need to do some post-processing to deliver a flac, wav, mp3 or whatever final format you prefer.

Using Freeswitch as the media server

When using Freeswitch, a bit of configuration is needed on the Freeswitch server. Specifically, you must implement a dialplan that:

  • allows unauthenticated INVITEs from the drachtio server
  • hairpins incoming calls back to the sender, by using the Freeswitch bridge application to send the B leg INVITE back to the source of the A leg INVITE
  • exports the custom 'X-Return-Token' header from the A leg to the B leg, and finally
  • makes a recording of the call.

An example snippet of a dialplan that does the trick looks like this:

  <extension name="hairpin_and_record">
    <condition field="${sip_h_X-Return-Token}" expression="^(.+)$">
      <action application="export" data="sip_h_X-Return-Token=${sip_h_X-Return-Token}" />
      <action application="export" data="_nolocal_jitterbuffer_msec=100"/>
      <action application="set" data="RECORD_STEREO=true"/>
      <action application="set" data="call_id=${strftime(%Y%m%d_%H%M%S)}_${sip_from_tag}"/>
      <action application="set" data="outfile=$${base_dir}/recordings/${call_id}.wav"/> 
      <action application="record_session" data="${outfile}"/>
      <action application="set" data="hangup_after_bridge=true"/> 
      <action application="bridge" data="sofia/external/${destination_number}@${network_addr}"/>
    </condition>
  </extension>

For an example docker image that implements, see davehorton/freeswitch-hairpin.

Note: when using Freeswitch, the application requires access to a redis server. redis is used to track and correlate the A and B call legs, using the X-Return-Token header mentioned above. When using rtpengine as the back-end, redis not required.

Using Asterisk as media server instead of Freeswitch

We can mimic the same behavior with Asterisk. For this to work we need to leave the 'config/local.json' as it is for freeswitch. Asterisk will receive a call and send another one back to drachtio sip server. The same steps described above can be done in Asterisk by modifying the pjsip.conf and extensions.conf files:

1- Allows authenticated INVITEs from drachtio server. Add these settings to your 'pjsip.conf' file:

[drachtio_in]
type=endpoint
context=siprec
disallow=all
allow=ulaw
allow=alaw
allow=g729
transport=transport-udp

[drachtio_out]
type=endpoint
context=siprec
disallow=all
allow=ulaw
allow=alaw
allow=g729
transport=transport-udp
aors=drachtio_out

[drachtio_in]
type=identify
endpoint=drachtio_in
match=<IP HERE>

[drachtio_out]
type=aor
contact=sip:<IP HERE>:5060

2- Hairpin the incoming call back to the server. Add these setings to your 'extensions.conf" file:

[siprec]
exten => _[+*#0-9]!,1,NoOp(Receiving call from drachtio)
exten => _[+*#0-9]!,n,Set(XReturnHeader=${PJSIP_HEADER(read,X-Return-Token)})
exten => _[+*#0-9]!,n,Progress()
;exten => _[+*#0-9]!,n,MixMonitor(${UNIQUEID}.wav)
;exten => _[+*#0-9]!,n,Monitor(wav,myfilename)
exten => _[+*#0-9]!,n,MixMonitor(${UNIQUEID}-mixed.wav,r(${UNIQUEID}-in.wav)t(${UNIQUEID}-out.wav))
exten => _[+*#0-9]!,n,Dial(PJSIP/${EXTEN}@drachtio_out,,b(addHeaders^addHeaderXRetHdr^1(${XReturnHeader})))
exten => _[+*#0-9]!,n,HangUp()


[addHeaders]
exten => addHeaderXRetHdr,1,Set(PJSIP_HEADER(add,X-Return-Token)=${ARG1})
same => n,Return()

Using dockerized versions of drachtio and rtpengine

If you haven't built the drachtio server and rtpengine processes (and don't want to), you can run using these docker images:

For guidance, have a look at the test suite, which uses docker-compose to create a test environment, as an example test/docker-compose-testbed.yaml.

Interoperability

This application has been tested with the following SIPREC clients:

  • Ribbon SBC 5200 (tested with Freeswitch back-end media server)
  • OpenSIPS (tested with rtpengine and Freeswitch back-end media servers)
  • Cisco Unified Border element (tested with rtpengine back-end media server)
  • Oracle Enterprise Session Border Controller

Test

npm test

Note: docker is required to run the test cases

How it works

The application receives the SIPREC INVITE from the SBC (or other SIPREC recording client), which will contain the multipart body with both SDP and XML metadata. The application parses the SDP to retrieve the two media endpoints that will be streaming from the SDP. What happens next is different depending on whether rtpengine or Freeswitch is being used.

When using rtpengine, the application creates two associated media endpoints on rtpengine (using the 'offer' and 'answer' commands in the ng protocol). The two media endpoints created by rtpengine are then combined into a multipart body 200 OK response that is returned to the SBC. The end result is that the caller media flows are directed to one of the rtpengin endpoints and the callee media flows to the other. The result is a recording made by rtpengine as if the caller and callee media flows were part of a call setup with rtpengine as a media proxy.

When using Freeswitch/Asterisk the same basic approach of sending the two media flows through Freeswitch/Asterisk as if it were a normal bridged call applies. In this case, the application sends an INVITE to the Freeswitch/Asterisk with one of the SDPs parsed from the SIPREC body and Freeswitch/Asterisk is responsible for generating a B leg back towards the drachtio server. Upon receving this B leg INVITE, the application answers 200 OK with remaining SDP parsed from the SIPREC body. A final 200 OK answer back to the SIPREC client is then generated, using the two media endpoints allocated on the Freeswitch/Asterisk. Media flows through the bridge connection and is recorded, as if caller were talking to callee through the Freeswitch/Asterisk.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].