Advanced recording rules
On this page:
Introduction
MiaRec supports very powerful recording filters, which allow to:
- specify which calls to record and which to ignore depending on call parameters (caller/callee ip-address, mac-address, telephone number etc.)
- change a default file naming for calls (for example, phones can be united into groups by their ip-addresses and every group is stored inside own directory)
Recording filters are specified inside section [Filters::OnCallStart] in MiaRec.ini configuration file.
Example:
[Filters::OnCallStart] filter1 condition = caller-number = '100' OR callee-number = '100' filter1 action = record filter2 condition = caller-number = '200' OR callee-number = '200' filter2 action = record filter3 condition = caller-number = '300' OR callee-number = '300' filter3 action = record default_action = ignore
In this example only those calls will be recorded, which are made from/to phones 100, 200 or 300.
All other calls will be ignored (see default_action = ignore).
Note, starting from version 5.0 MiaRec supports configuring per-user recording rules via web interface. These per-user rules are executed after recording filters in INI file. Recording filters from INI file are always executed first. If one of filter's condition matches, then per-user rules are not executed. This allows to configure some advanced global ignore rules, like "ignore all internal calls":
[Filters::OnCallStart] # Ignore all internal calls, where both caller and called phone numbers are 3 digits. filter_internal_calls_action = ignore filter_internal_calls_condition = caller-number LIKE '___' AND callee-number LIKE '___'
Syntax of filters
Syntax of filters is following:
<unique-name-of-filter>condition = CONDITION <unique-name-of-filter>action = [ record | ignore ] <unique-name-of-filter>filename = FILENAME-FORMAT
Each filter has unique name and consits of three lines: action, condition and filename. The last line (filename) is optional.
Name of filter
Each recording filter should have unique name. For example:
[Filters::OnCallStart] filter1_condition = caller-number = 12345 filter1_action = record filter2_condition = caller-ip = 10.0.0.0/24 filter2_action = record filter2_filename = C:\Calls\Network2\%{setup-time#%Y%m%d%H%M%S}.mp3 my new filter condition = caller-ip = 10.0.5.0/24 my new filter action = ignore
In this example three filters are specified with the following names:
- filter1_
- filter2_
- my new filter
Filter name may contain letters, digits, underscore and space characters.
Condition of filter
condition is a logical expression. Example:
filter1 condition = caller-ip = 192.168.0.1 filter2 condition = caller-ip >= 192.168.0.10 AND caller-ip <= 192.168.0.20 filter3 condition = caller-number LIKE '011%' filter4 condition = caller-ip = 10.0.0.5 AND NOT (callee-ip = 10.0.0.1 OR callee-ip = 10.0.0.2)
Read Syntax of filter condition for details.
Action of filter
action specifies what to do with a call. Following actions are supported:
Action | Description |
---|---|
record | Record the call, which matches that filter's condition. If filename line exists, then call will be recorded with specified name, otherwise the default file name will be used. |
ignore | Ignore a call (do not record it). Audio file for that call will not be stored on disk and normally such call will not be visible inside MiaRec web-interface. But, optionally, it is possible to show ignored calls inside MiaRec web-interface (see SaveCDRsForIgnoredCalls). |
Filename
filename specifies a file name format for calls, which match the filter's condition. It is optional. If it is omitted, then a default file name format is used as specified in section [Recording] parameter FileNameFormat. A syntax of this field is the same (see File name format).
Default action
Note, starting from version 5.2 a default action is configured inside web-interfaces. Settings for default action inside INI file are ignored during normal system operation. Although they are used when MiaRec recorder functions without a database.
For calls, which do not match any of recording filters, a default action is performed. Default action may be record or ignore. Optionally, a default file name format (default_filename) can be specified.
Example:
[Filters::OnCallStart] filter1_condition = caller-number = '123456' OR callee-number = '123456' filter1_action = record default_action = ignore
In above example only phone with number '123456' will be recorded. All other calls will be ignored (see default_action = ignore).
Optionally, you can specify default_filename. This parameter will override the one, which is specified inside FileNameFormat in section [Recording].
Example:
[Filters::OnCallStart] filter1_condition = caller-number = '123' OR callee-number = '123' filter1_action = record filter1_filename = C:\Phone123\%{setup-time#%Y%m%d%H%M%S}.mp3 default_action = record default_filename = C:\OtherPhones\%{setup-time#%Y%m%d%H%M%S}.mp3
In this example, calls with number 123 will be stored inside directory C:\Phone123\.
All other calls will be stored inside directory C:\OtherPhones\.
Note, if a default action is omitted, then it has implicit value record.
Order of filters
The order of filters is important when a call may match multiple filters. In this case the first matched filter is used.
For example, we have following filters:
[Filters::OnCallStart] filter1_action = record filter1_condition = caller-ip = '192.168.0.0/24' filter2_action = ignore filter2_condition = caller-port = 5060
And our call has caller-ip equal to 192.168.0.5 and caller-ip equal to 5060.
Such call will match a condition of both filters, but action of the first one will be pefrormed (record).
If you change the order of filters inside INI file, like:
[Filters::OnCallStart] filter2_action = ignore filter2_condition = caller-port = 5060 filter1_action = record filter1_condition = caller-ip = '192.168.0.0/24'
Then the mentioned call will be ignored because first matched filter has action ignore.
Troubleshooting
When recording filters are not working as you expected, then use the following recommendations:
- Look at Windows Event Log (Control Panel -> Administration -> Event Viewer). If syntax of recording filter is incorrect, MiaRec will write an error message to Windows Event Log.
- Change SaveCDRsForIgnoredCalls parameter inside MiaRec.ini to 1. Normally, ignored calls are not visible inside MiaRec calls history. When SaveCDRsForIgnoredCalls = 1, the ignored calls will be shown inside MiaRec with a special icon and message "Ignored by filters". This will allow you to see if the problem is in your filters. Read details here: SaveCDRsForIgnoredCalls.
- Verify that recording filters have phone number/name in the same format as they appear inside MiaRec web-interface. Sometimes you may expect that your phones have extension 2XX (for example), but, in reality, they are 92XX (with additional prefix). MiaRec extracts phone numbers from voip signaling messages, which are sent by your phones. You should create recording filters with exactly the same phone numbers as they are visible to MiaRec.