rtpengine-recording(8)

NAME
rtpengine-recording - media recording daemon for Sipwise rtpengine

SYNOPSIS
rtpengine-recording [option...]

DESCRIPTION
The Sipwise rtpengine media proxy has support for exporting media (RTP) packets that it forwards. The rtpengine-recording daemon collects these exported packets and decodes them into an audio format that can be listened to.

OPTIONS
All options can (and should) be provided in a config file instead of at the command line. See the --config-file option below for details.

If no options are given, then default values are assumed, which should be sufficient for a standard installation of rtpengine.

•   --help

    Print the usage information.

•   -v, --version

    If called with this option, the rtpengine-recording daemon will simply print its version number and exit.

•   --config-file=FILE

    Specifies the location of a config file to be used. The config file is an .ini style config file, with all command-line options listed here also being valid options in the config file. For all command-line options, the long name version instead of the single-character version (e.g. table instead of just t) must be used in the config file. For boolean options that are either present or not (e.g. output-mixed), a boolean value (either true or false) must be used in the config file. If an option is given in both the config file and at the command line, the command-line value overrides the value from the config file.

    As a special value, none can be passed here to suppress loading of the default config file.

•   --config-section=STRING

    Specifies the .ini style section to be used in the config file. Multiple sections can be present in the config file, but only one can be used at a time. The default value is rtpengine-recording. A config file section is started in the config file using square brackets (e.g. [rtpengine-recording]).

•   -L, --log-level=INT

    Takes an integer as argument and controls the highest log level which will be sent to syslog. The log levels correspond to the ones found in the syslog(3) (http://man.he.net/man3/syslog) man page. The default value is 6, equivalent to LOG_INFO. The highest possible value is 7 (LOG_DEBUG) which will log everything.

•   --log-facilty=daemon|local0|...|local7|...

    The syslog facilty to use when sending log messages to the syslog daemon. Defaults to daemon.

•   -E, --log-stderr

    Log to stderr instead of syslog. Only useful in combination with --foreground.

•   --split-logs

    Split multi-line log messages into individual log messages so that each line receives its own log line prefix.

•   --no-log-timestamps

    Don’t add timestamps to log lines written to stderr. Only useful in combination with --log-stderr.

•   --log-mark-prefix=STRING

    Prefix to be added to particular data fields in log files that are deemed sensitive and/or private information. Defaults to an empty string.

•   --log-mark-suffix=STRING

    Suffix to be added to particular data fields in log files that are deemed sensitive and/or private information. Defaults to an empty string.

•   -p, --pidfile=FILE

    Specifies a path and file name to write the daemon’s PID number to.

•   -f, --foreground

    If given, prevents the daemon from daemonizing, meaning it will stay in the foreground. Useful for debugging.

•   -t, --table=INT

    Takes an integer argument. The value must match the table option given to the rtpengine media proxy to use for in-kernel packet forwarding. Defaults to 0 if not specified.

•   --spool-dir=PATH

    The path given here must match the recording-dir path given to the rtpengine media proxy. Defaults to /var/spool/rtpengine. The path must reside on a file system that supports the inotify mechanism.

•   --num-threads=INT

    How many worker threads to launch. Defaults to the number of CPU cores available, or 8 if there are fewer than that or if the number is not known.

•   --thread-stack=INT

    Set the stack size of each thread to the value given in kB. Defaults to 2048 kB. Can be set to -1 to leave the default provided by the OS unchanged.

•   --evs-lib-path=FILE

    Points to the shared object file (.so) containing the reference implementation for the EVS codec. See the README for more details.

•   --output-storage=file|db|memory|notify|s3|gcs|none

    Where to store media files. This option can be given multiple times (or, in the config file, using a comma-separated list) to enable multiple storage modes. By default only the file storage is enabled.

    The file storage writes media files directly to the file system (see output-dir).

    Setting none overrides file storage as being the default and allows forwarding-only operation.

    The db storage writes media files as a BLOB in a MySQL database.

    The string both is recognised as legacy alternative to enabling both file and db storage.

    The notify output attaches the recording to the HTTP notification request. If enabled, notification requests behave as HTTP POST (implicitly enabling notify-post).

    The string memory acts as a modifier and can be used if file storage is not enabled. Without the memory modifier, media is first written to a temporary file before being placed into its destination storage when recording is finished. With memory set, use of temporary files is disabled and media is kept in memory only until recording is complete.

    db-mem can be used as a shortcut to setting both db and memory.

    The s3 storage option enables upload to an S3-compatible service via HTTPS, for example to AWS or MiniO. See the related option below for configuration.

    Use the gcs storage option to enable uploads to Google Cloud Storage or a compatible service. See the related options below.

•   --output-dir=PATH

    Path for media files to be written to if file output is enabled. Defaults to /var/lib/rtpengine-recording. The path must not be the same as used for the spool-dir.

•   --output-pattern=STRING

    File name pattern to be used for recording files. The pattern can reference sub-directories. Parent directories will be created on demand. The default setting is %c-%r-%t.

    The pattern must include printf-style format sequences. Supported format sequences are:

    •   %%

        A literal percent sign.

    •   %c

        The call ID. It is mandatory for the output pattern to include this format sequence.

    •   %r

        A random tag generated by rtpengine to distinguish possibly repeated or duplicated call IDs.

    •   %t

        The stream type. For single streams this is the SSRC written as hexadecimal; for mix stream this is the string mix. It is mandatory for the output pattern to include this format sequence.

    •   %l

        The label for the participating party as communicated from the controlling daemon.

    •   %Y

    •   %m

    •   %d

    •   %H

    •   %M

    •   %S

        These format sequence reference the current system time (when the output file was created) and are the same as the format sequences supported by date(1) (http://man.he.net/man1/date) or strftime(3) (http://man.he.net/man3/strftime) (year, month, day, hours, minutes, and seconds, respectively).

    •   %u

        Microseconds, expanded to 6 digits (000000 through 999999).

    •   %INT

        References a prefix from the call ID of the given length. If this format sequence is present more than once, then the prefixes are cumulative. For example, if the call ID is abcdefgh and the output pattern is configured as %2/%3/%c, then the resulting output file name would be ab/cde/abcdefgh.

    •   %{

        Take the string between the enclosing opening and closing brace (between this { and the next }) and use it as a key to look up a corresponding value in the metadata string provided by rtpengine. The metadata string must be given as a pipe (|) separated list of key:value pairs, as described in the rtpengine documentation.

        Example: If the metadata string is given as foo:bar|blah:baz and the pattern includes the format %{foo} then bar will be inserted into the file name at that position.

•   --output-format=wav|mp3|none

    File format to be used for media files that are produced. Defaults to PCM WAV (RIFF) files. Applicable for both files stored on the file system and in a database.

    none is a legacy alias for output-storage=none.

•   --resample-to=INT

    Resample all audio to the given sample rate (e.g. 48000). Resampling is disabled by default, meaning that files will be written with the same sample rate as the source media.

•   --mp3-bitrate=INT

    If MP3 output is selected, use the given bitrate for the MP3 encoder (e.g. 64000). There is no default value, so this option must be given if MP3 output is selected. Note that not all bitrates are valid in combinations with all sample rates. For MP3 output it’s therefore recommended to also set resample-to.

•   --output-mixed

•   --output-single

    Whether to produce mixed audio files, or single audio files, or both. If neither option is given, then by default both are enabled. If no file output is desired, set output-format to none.

    A single audio file contains the audio for a single RTP SSRC, which usually means an unidirectional audio stream. These are decoded directly from an RTP stream and do not take timestamping into account, meaning that gaps or pauses in the RTP stream are not reflected in the output audio file.

    A mixed audio file consists of the first four RTP SSRC seen, mixed together into a single output file, which usually means that a bidirectional audio stream is produced. Audio mixing takes RTP timestamping into account, so gaps and pauses in the RTP media are reflected in the output audio to keep the multiple audio sources in sync.

•   --mix-method=direct|channels

    Selects a method to mix multiple audio inputs into a single output file for mixed output. The default is direct which directly mixes all audio inputs together, producing a mixed output file with the same format as an audio file from a single input (output-single) would be.

    The channels mixing method puts each audio input into its own audio channel in the output file, therefore producing a multi-channel output file. Up to four separate RTP SSRCs are supported for a mixed output, which means that if each input is mono audio, then the mixed output file would contain 4 audio channels. This mixing method requires an output file format which supports these kinds of multi-channel audio formats (e.g. wav).

•   --mix-num-inputs=INT

    Change the number of recording channel in the output file. The value is between 1 to 4 (e.g. 4, which is also the default value).

•   --output-chmod=INT

    Change the file permissions of recording files to the given mode. Must be given as an octal integer, for example 0660.

•   --output-chmod-dir=INT

    Change the file permissions of recording files to the given mode. Must be given as an octal integer, for example 0700 (which is also the default value).

•   --output-chown=USER|UID

•   --output-chgrp=GROUP|GID

    Change the ownership of recording files. Either user/group names or numeric IDs are supported. If the value is blank or given as -1 then the user/group is left unchanged.

•   --output-buffer=INT

    Set the size of the I/O buffer used for writing files. The default is 2^18 bytes (256 kB). Can be set to zero to effect unbuffered I/O.

•   --mysql-host=HOST|IP

•   --mysql-port=INT

•   --mysql-user=USERNAME

•   --mysql-pass=PASSWORD

•   --mysql-db=STRING

    Configuration for a MySQL storage backend. Details about calls and media files that are produced are stored into the database. Optionally the media files themselves can be stored as well (see output-storage).

    For MySQL database schema, see Database schema

•   --forward-to=PATH

    Forward raw RTP packets to a Unix socket. Disabled by default.

•   --tcp-send-to=IP:PORT

•   --tcp-resample=INT

•   __--tcp-mixed

•   --tls-send-to=IP:PORT

•   --tls-resample=INT

•   __--tls-mixed

    Send decoded audio over a TCP or TLS connection to the specified destination. Audio is sent as raw 16-bit PCM in the given sample rate.

    By default one connection with one mono audio stream will be established for each SSRC. If mixed mode is enabled, then similar to the mixed file output one connection per call will be established instead, containing audio mixed together from all captured SSRCs. The mix-method setting is honoured in the same way, so the audio will be either mono or mulit-channel depending on the setting.

    Only one of these option combinations (TCP or TLS) can be active at the same time.

•   --notify-uri=URI

    Enable HTTP notification about finished recordings to the specified URI, which must be an HTTP or HTTPS URI. Information about the finished recording is provided via custom HTTP headers, all of which use a prefix of X-Recording-.

•   --notify-post

    Use HTTP POST instead of GET for the HTTP notification requests. The request body is empty even if POST is used.

•   --notify-no-verify

    Disable TLS peer certificate verification for HTTPS requests.

•   --notify-command=PATH

    External command to launch to send a notification about a new recording. The command will receive two command line arguments: The full path and file name of the recording, and the ID number from the database entry.

•   --notify-concurrency=INT

    The maximum number of HTTP requests to perform simultaneously.

•   --notify-retries=INT

    How many times to retry a failed HTTP notification before giving up. An exponential falloff time is used for each subsequent attempt, starting with 5 seconds.

•   --notify-record

    Legacy alias for output-storage=notify. If no other output storage is enabled, then the default file storage remains enabled (unless the following option is also set).

•   --notify-purge

    Legacy option to disable the default file storage when notification output is enabled.

•   --output-mixed-per-media

    Forces one channel per media instead of SSRC. Note that this option is only useful if --output-mixed is also enabled.

•   --flush-packets

    Forces that the output buffer will be flushed after every packet, ensuring that the recording file grows steadily and becomes available for processing without delays.

•   --s3-host=HOST

•   --s3-port=INT

•   --s3-path=STR

•   --s3-access-key=STR

•   --s3-secret-key=STR

•   --s3-region=STR

•   --s3-no-verify

    These options must be configured if S3 storage upload is enabled. The port is optional and defaults to 443 (HTTPS) if not configured.

    The host name may or may not need to include the bucket name. For example minio.example.com or examplebucket.s3.amazonaws.com.

    The path can be blank if the host name includes the bucket name. Otherwise the bucket name becomes part of the path (such as /examplebucket). This option must still be set even if the path is blank.

    Access key and secret key are the credentials provided by the service (e.g. AKIAIOSFODNN7EXAMPLE and wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY).

    The region code is part of the credentials (e.g. us-east-1). If the service doesn’t use a region code, then this must be set to a blank string.

    TLS certificates are verified by default, unless the no-verify option is set.

•   --gcs-uri=URI

•   --gcs-key=STR

•   --gcs-service-account=FILE

•   --gcs-scope=STR

•   --gcs-no-verify

    Configure these settings to use GCS storage. At least the URI and an authentication method must be set.

    The gcs-uri must point to the full URI to post uploads to. Typically it would contain the name of the storage bucket. The URI must not contain a query string (i.e. no ?). For example: https://storage.googleapis.com/upload/storage/v1/b/examplebucket/o

    For authentication, either an API key must be provided via gcs-key, or OAuth2 authentication via a service account file must be configured.

    To use OAuth2/JWT authentication, the gcs-service-account setting must point to a service account file in JSON format. This file should at least contain a client_email, a private_key in RSA/PEM format, and a token_uri. The authentication scope defaults to https://www.googleapis.com/auth/cloud-platform but can be changed via gcs-scope.

    Set gcs-no-verify to disable TLS certificate verification. Note that this only applies to uploads themselves, not to OAuth2 requests.

EXIT STATUS

•   0

    Successful termination.

•   1

    An error occurred.

FILES

•   /etc/rtpengine/rtpengine-recording.conf

    Configuration file.

DATABASE SCHEMA
Saving recording into MySQL database requires correct database schema:

        CREATE TABLE `recording_calls` (
          `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
          `call_id` varchar(250) NOT NULL,
          `start_timestamp` decimal(13,3) DEFAULT NULL,
          `end_timestamp` decimal(13,3) DEFAULT NULL,
          `status` enum('recording','completed','confirmed') DEFAULT 'recording',
          PRIMARY KEY (`id`),
          KEY `call_id` (`call_id`)
        );

        CREATE TABLE `recording_streams` (
          `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
          `call` int(10) unsigned NOT NULL,
          `local_filename` varchar(250) NOT NULL,
          `full_filename` varchar(250) NOT NULL,
          `file_format` varchar(10) NOT NULL,
          `stream` mediumblob,
          `output_type` enum('mixed','single') NOT NULL,
          `stream_id` int(10) unsigned NOT NULL,
          `sample_rate` int(10) unsigned NOT NULL DEFAULT '0',
          `channels` int(10) unsigned NOT NULL DEFAULT '0',
          `ssrc` int(10) unsigned NOT NULL,
          `start_timestamp` decimal(13,3) DEFAULT NULL,
          `end_timestamp` decimal(13,3) DEFAULT NULL,
          `tag_label` varchar(255) NOT NULL DEFAULT '',
          PRIMARY KEY (`id`),
          KEY `call` (`call`),
          CONSTRAINT `fk_call_id` FOREIGN KEY (`call`) REFERENCES `recording_calls` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
        );

        CREATE TABLE `recording_metakeys` (
          `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
          `call` int(10) unsigned NOT NULL,
          `key` char(255) NOT NULL,
          `value` char(255) NOT NULL,
          PRIMARY KEY (`id`),
          KEY `prim_lookup` (`value`,`key`),
          KEY `fk_call_idx` (`call`),
          CONSTRAINT `fk_call_idx` FOREIGN KEY (`call`) REFERENCES `recording_calls` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
        );

SEE ALSO
rtpengine(8) (http://man.he.net/man8/rtpengine) .