On this page:
MiaRec supports very powerful recording filters, which allow to:
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).
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.
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:
Filter name may contain letters, digits, underscore and space characters.
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 = 192.168.0.1 AND NOT (callee-ip == 10.0.0.1 OR 10.0.0.2)
Read Syntax of filter condition for details.
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 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).
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.
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 all 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.
When recording filters are not working as you expected, then use the following recommendations: