rtpengineclient v0.1.6 RtpEngineClient
This is a client for the Sipwise NGCP RtpEngine proxy. This client assumes
you have configured the daemon to support the NG protocol, where the
RtpEngine can rewrite the SDP parameters (argument --listen-ng).
Summary
Functions
Sends a SDP answer to RtpEngine proxy
Lists the currently active call-ids
Sends a SDP offer to RtpEngine proxy
Pings the RtpEngine service
Queries a specific active call
Starts the RtpEngine client
Types
delete_option :: branch_option | to_tag_option | {:flags, [:fatal]} | {:delay, seconds :: integer}
flag_option :: :sip_source_address | :trust_address | :symmetric | :asymmetric | :unidirectional | :strict_source | :media_handover | :reset | :port_latching | :record_call
received_from_option() :: {:received_from, {family :: :inet | :inet6, String.t} | :inet.ip_address}
sdes_flags :: :unencrypted_srtp | :unencrypted_srtcp | :unauthenticated_srtp | :encrypted_srtp | :encrypted_srtcp | :authenticated_srtp
Functions
Sends a SDP answer to RtpEngine proxy.
sdp is the complete SDP body as string. call_id is the SIP Call-ID header
value as string. from_tag is the SIP From header tag parameter as
string. to_tag is the SIP To header tag parameter as string.
The timeout parameter indicates the time in milliseconds to wait for a
RtpEngine response, the default is 10 seconds.
The optional parameters are identical to the offer/5 function, except that
the :direction does not make sense in the answer message.
delete(call_id, from_tag, delete_options, timeout) :: on_delete
Deletes a call created by the offer/5 and answer/6 functions.
call_id is the SIP Call-ID header value as string. from_tag is the SIP
From header tag parameter as string.
The timeout parameter indicates the time in milliseconds to wait for a
RtpEngine response, the default is 10 seconds.
Optional parameters are:
:to_tagis the SIPToheadertagparameter as string. Used to additionally refine the matching logic between media streams and calls and call branches.:branchis the topmost SIPViaheaderbranchparameter as string. Used to additionally refine the matching logic between media streams and calls and call branches.:flagsspecifies a list of flags to turn on::fatalspecifies that any non-syntactical error encountered when deleting the stream (such as unknowncall_id) shall result in an error. The default is to log warnings and return:ok.
:delayspecifies an integer representing the time in seconds in which the call should be deleted. If zero, the call will be immediately deleted.
Lists the currently active call-ids.
You may specify an optional argument :limit that indicates the maximum
number of results in the reply, otherwise the default is 32.
The timeout parameter indicates the time in milliseconds to wait for a
RtpEngine response, the default is 10 seconds.
offer(sdp, call_id, from_tag, offer_opts, timeout) :: on_reply
Sends a SDP offer to RtpEngine proxy.
sdp is the complete SDP body as string. call_id is the SIP Call-ID header
value as string. from_tag is the SIP From header tag parameter as
string.
The timeout parameter indicates the time in milliseconds to wait for a
RtpEngine response, the default is 10 seconds.
Optional parameters are:
:branchis the topmost SIPViaheaderbranchparameter as string. Used to additionally refine the matching logic between media streams and calls and call branches.:flagsis an atom list of::sip_source_addressignores any IP addresses given in the SDP body and use the source address of the received SIP message (given in:received_from) as default endpoint address. This was the default behaviour of older versions of RtpEngine and can still be made the default behaviour through the--sip-sourceCLI switch. Can be overridden through the:media_addresskey.:trust_addressdoes the opposite of:sip_source_address. This is the default behaviour unless the CLI switch--sip-sourceis active. Corresponds to the rtpproxyrflag. Can be overridden through the:media_addresskey.:symmetriccorresponds to the rtpproxywflag. Not used by RtpEngine as this is the default, unless:asymmetricis specified.:asymmetriccorresponds to the rtpproxyaflag. Advertises an RTP endpoint which uses asymmetric RTP, which disables learning of endpoint addresses (see below).:unidirectionalkernelizes also one-way rtp media.:strict_sourcecontinues to inspect the source address and port of incoming packets after the learning phase and compare them with the endpoint address that has been learned before. If there’s a mismatch, the packet will be dropped and not forwarded. Without this flag, RtpEngine will attempt to learn the correct endpoint address for every stream during the first few seconds after signalling by observing the source address and port of incoming packets (unless:asymmetricis specified). Afterwards, source address and port of incoming packets are normally ignored and packets are forwarded regardless of where they’re coming from.:media_handoveris similar to the:strict_sourceoption, but instead of dropping packets when the source address or port don’t match, the endpoint address will be re-learned and moved to the new address. This allows endpoint addresses to change on the fly without going through signalling again. Note that this opens a security hole and potentially allows RTP streams to be hijacked, either partly or in whole.:resetcauses RtpEngine to un-learn certain aspects of the RTP endpoints involved, such as support for ICE or support for SRTP. For example, ifice: :forceis given, then RtpEngine will initially offer ICE to the remote endpoint. However, if a subsequent answer from that same endpoint indicates that it doesn’t support ICE, then no more ICE offers will be made towards that endpoint, even ifice: :forceis still specified. With the reset flag given, this aspect will be un-learned and RtpEngine will again offer ICE to this endpoint. This flag is valid only in an offer message and is useful when the call has been transferred to a new endpoint without change ofFromorTotags.:port_latchingforces RtpEngine to retain its local ports during a signalling exchange even when the remote endpoint changes its port.:record_callis identical to settingrecord_call: true(see below).
:replaceis similar to the flags list. Controls which parts of the SDP body should be rewritten. Contains zero or more of::originreplaces the address found in the origin (o=) line of the SDP body. Corresponds to rtpproxyoflag.:session_connectionreplaces the address found in the session-level connection (c=) line of the SDP body. Corresponds to rtpproxycflag.
:directioncontains a tuple of two strings and corresponds to the rtpproxyeandiflags. Each element must correspond to one of the named logical interfaces configured on the command line (through--interface). For example, if there is one logical interface namedpuband another one namedpriv, then if side A (originator of the message) is considered to be on the private network and side B (destination of the message) on the public network, then that would be rendered asdirection: {"priv", "pub"}. This only needs to be done for an initial offer; for the answer and any subsequent offers (between the same endpoints) RtpEngine will remember the selected network interface. A direction keyword is:round_robin_calls. If this is specified, a round robin algorithm runs for choosing the logical interface for the current stream (e.g. audio, video). The algorithm checks that all local interfaces of the tried logical interface have free ports for call streams. If a logical interface fails the check, the next one is tried. If there is no logical interface found with this property, it fallbacks to the default behaviour (e.g. return first logical interface in--interfacelist even if no free ports are available). The attribute is ignored for answers because the logical interface was already selected at offers. Note that naming an interface asround-robin-callsand trying to select it using direction will run the above algorithm!:received_fromcontains a tuple of two elements where the first element denotes the address family (:inetor:inet6) and the second element is the SIP message’s source address itself. It can be also the SIP message’s source IP address tuple as specified in:inet.ip_address(), and in this case the family is obtained automatically. Used if SDP addresses are neither trusted (through the flag:sip_source_addressor the command line argument--sip-source) nor the:media_addresskey is present.:icecontains either:remove,:forceor:force_relay. With:remove, any ICE attributes are stripped from the SDP body. With:force, ICE attributes are first stripped, then new attributes are generated and inserted, which leaves the media proxy as the only ICE candidate. The default behavior (no ICE key present at all) is: if no ICE attributes are present, a new set is generated and the media proxy lists itself as ICE candidate; otherwise, the media proxy inserts itself as a low-priority candidate. With:force_relay, existing ICE candidates are left in place except relay type candidates, and RtpEngine inserts itself as a relay candidate. It will also leave SDPc=andm=lines unchanged. This flag operates independently of the replace flags.:transport_protocolrewrites the transport protocol specified in the SDP body. The media proxy expects to receive this protocol on the allocated ports, and will talk this protocol when sending packets out. Translation between different transport protocols will happen as necessary. Valid values are:"RTP/AVP","RTP/AVPF","RTP/SAVP","RTP/SAVPF".:media_addresscan be used to override both the addresses present in the SDP body and the received from address. Contains either an IPv4 or an IPv6 address, expressed as simple string or one of the:inet.ip_address()tuples. The format must be dotted-quad notation for IPv4 or RFC 5952 notation for IPv6. It’s up to the RTP proxy to determine the address family type.:address_familyis either:inetor:inet6to select the primary address family in the substituted SDP body. The default is to auto-detect the address family if possible (if the recieving end is known already) or otherwise to leave it unchanged.:rtcp_muxis a list of atoms controlling the behaviour regarding rtcp-mux (multiplexing RTP and RTCP on a single port, RFC 5761). The default behaviour is to go along with the client’s preference. The list can contain zero of more of the following atoms. Note that some of them are mutually exclusive.:offerinstructs RtpEngine to always offer rtcp-mux, even if the client itself doesn’t offer it.:demuxdon’t offer it to the other side if the client is offering rtcp-mux, but accept it back to the offering client.:acceptinstructs RtpEngine to accept rtcp-mux and also offer it to the other side if it has been offered.:rejectrejects rtcp-mux if it has been offered. Can be used together with:offerto achieve the opposite effect of:demux.
:toscontains an integer representing the TOS value used in outgoing RTP packets of all RTP streams in all directions. If a negative value is used, the previously used TOS value is left unchanged. If this key is not present or its value is too large (256 or more), then the TOS value is reverted to the default (as per--toscommand line argument).:dtlscontains eitherfalseor:passive, and influences the behaviour of DTLS-SRTP. Their meanings are:falseprevents RtpEngine from offering or acceping DTLS-SRTP when otherwise it would. The default is to offer DTLS-SRTP when encryption is desired and to favour it over SDES when accepting an offer.:passiveinstructs RtpEngine to prefer the passive (i.e. server) role for the DTLS handshake. The default is to take the active (client) role if possible. This is useful in cases where the SRTP endpoint isn’t able to receive or process the DTLS handshake packets, for example when it’s behind NAT or needs to finish ICE processing first.
:sdesis a list of options controlling the behaviour regarding SDES. The default is to offer SDES without any session parameters when encryption is desired, and to accept it when DTLS-SRTP is unavailable. If two SDES endpoints are connected to each other, then the default is to offer SDES with the same options as were received from the other endpoint.falseprevents RtpEngine from offering SDES, leaving DTLS-SRTP as the other option.:unencrypted_srtp,:unencrypted_srtcpand:unauthenticated_srtpenable the respective SDES session parameter (see section 6.3 or RFC 4568). The default is to copy these options from the offering client, or not to have them enabled if SDES wasn’t offered.:encrypted_srtp,:encrypted_srtcpand:authenticated_srtpnegates the respective option. This is useful if one of the session parameters was offered by an SDES endpoint, but it should not be offered on the far side if this endpoint also speaks SDES.
:record_callis a boolean flag telling whether to record the call to PCAP files. If the call is recorded, it will generate PCAP files for each stream and a metadata file for each call. Note that RtpEngine will not force itself into the media path, and other flags likeice: :forcemay be necessary to ensure the call is recorded. See the--recording-dirRtpEngine argument. Enabling call recording via this option has the same effect as doing it separately via the start recording message, except that this option guarantees that the entirety of the call gets recorded, including all details such as SDP bodies passing through RtpEngine.:metadatais a generic metadata string. The metadata will be written to the bottom of metadata files within/path/to/recording_dir/metadata/. This can be used to record additional information about recorded calls.:metadatavalues passed in through subsequent messages will overwrite previous metadata values. See the--recording-dirRtpEngine argument.
Pings the RtpEngine service.
Queries a specific active call.
call_id is the SIP Call-ID header value as string.
Among the optional parameters, you may specify the from_tag as being the
SIP From header tag parameter as string, and the to_tag as the SIP To
header tag parameter as string.
Starts the RtpEngine client.
The rtpengine_address parameter is an URI in the form of
"udp://hostname:port", where the hostname and port are those of the
RtpEngine instance to access. If port is omitted, the UDP port 2223 is
assumed.