I’m writing a c# sip phone application and i need to get call records. Im using PortSip as client sip library. And there is a problem with it: the library has call recording functionality, but ~10% of calls are not recording(Dont know why, even restarting StartRecording doesn’t help, it just cant start recording of current call).
So ive decided to record calls on asterisk server and download them to our database after call ending. Asterisk CDR data is stored in mysql database and i cant see any unique callId there. I wonder if we can write call records in a table into database to get them by some keys, related to cdr?
Or another option that I see is to records all calls on the asterisk server, download needed one to our computer via ftp and save it to our servers.
I’m writing a c# sip phone application and i need to get call records.
Share
I would definitely have asterisk record the calls instead of the sip devices. You can record calls in asterisk by using the Monitor command in your dialplan, like:
This will automatically record all calls to the 555 extension (you can use a dialplan pattern to automatically record all calls to all extensions, but this will depend on your particular setup). You could also run an AGI script to discriminate which calls are to be recorded, if you dont want to record all of them.
The target filename can be composed by the ani-dnis-datetime to make it unique or with any other asterisk variables. For example: ${CALLERID(ani)}-${EXTEN}. You can also use the unique call id variable ${UNIQUEID}, like ${CALLERID(ani)}-${EXTEN}-${UNIQUEID}.
As for the CDR, you can have it as a csv, or sqlite file, or a relational database like mysql, postgresql, etc by using the cdr_odbc module.
What makes a call unique is the uniqueid field. So in your CDR you would have the source, the destination, the channels involved, dates, answered time, dial status, etc, and also this uniqueid field, so you can relate a given call with a given audio file (the recorded call) and with the involved sip devices. The wav files can be downloaded and backed up periodically if needed.
Hope it helps!