uvgRTP 3.1.3
An open-source library for RTP/SRTP media delivery
Loading...
Searching...
No Matches
util.hh File Reference

Go to the source code of this file.

Typedefs

typedef enum RTP_ERROR rtp_error_t
 
typedef enum RTP_FORMAT rtp_format_t
 
typedef enum RTP_FLAGS rtp_flags_t
 

Enumerations

enum  RTP_ERROR {
  RTP_OK = 0 ,
  RTP_GENERIC_ERROR = -1 ,
  RTP_SOCKET_ERROR = -2 ,
  RTP_BIND_ERROR = -3 ,
  RTP_INVALID_VALUE = -4 ,
  RTP_SEND_ERROR = -5 ,
  RTP_MEMORY_ERROR = -6 ,
  RTP_SSRC_COLLISION = -7 ,
  RTP_INITIALIZED = -8 ,
  RTP_NOT_INITIALIZED = -9 ,
  RTP_NOT_SUPPORTED = -10 ,
  RTP_RECV_ERROR = -11 ,
  RTP_TIMEOUT = -12 ,
  RTP_NOT_FOUND = -13 ,
  RTP_AUTH_TAG_MISMATCH = -14
}
 RTP error codes. More...
 
enum  RTP_FORMAT {
  RTP_FORMAT_GENERIC = 0 ,
  RTP_FORMAT_PCMU = 0 ,
  RTP_FORMAT_GSM = 3 ,
  RTP_FORMAT_G723 = 4 ,
  RTP_FORMAT_DVI4_32 = 5 ,
  RTP_FORMAT_DVI4_64 = 6 ,
  RTP_FORMAT_LPC = 7 ,
  RTP_FORMAT_PCMA = 8 ,
  RTP_FORMAT_G722 = 9 ,
  RTP_FORMAT_L16_STEREO = 10 ,
  RTP_FORMAT_L16_MONO = 11 ,
  RTP_FORMAT_G728 = 15 ,
  RTP_FORMAT_DVI4_441 = 16 ,
  RTP_FORMAT_DVI4_882 = 17 ,
  RTP_FORMAT_G729 = 18 ,
  RTP_FORMAT_G726_40 = 96 ,
  RTP_FORMAT_G726_32 = 97 ,
  RTP_FORMAT_G726_24 = 98 ,
  RTP_FORMAT_G726_16 = 99 ,
  RTP_FORMAT_G729D = 100 ,
  RTP_FORMAT_G729E = 101 ,
  RTP_FORMAT_GSM_EFR = 102 ,
  RTP_FORMAT_L8 = 103 ,
  RTP_FORMAT_VDVI = 104 ,
  RTP_FORMAT_OPUS = 105 ,
  RTP_FORMAT_H264 = 106 ,
  RTP_FORMAT_H265 = 107 ,
  RTP_FORMAT_H266 = 108 ,
  RTP_FORMAT_ATLAS = 109
}
 These flags are given to uvgrtp::session::create_stream() More...
 
enum  RTP_FLAGS {
  RTP_NO_FLAGS = 0 ,
  RTP_COPY = 1 << 1 ,
  RTP_NO_H26X_SCL = 1 << 2 ,
  RTP_H26X_DO_NOT_AGGR = 1 << 3
}
 These flags are given to uvgrtp::media_stream::push_frame() and they can be OR'ed together. More...
 
enum  RTP_CTX_ENABLE_FLAGS {
  RCE_NO_FLAGS = 0 ,
  RCE_SEND_ONLY = 1 << 1 ,
  RCE_RECEIVE_ONLY = 1 << 2 ,
  RCE_SRTP = 1 << 3 ,
  RCE_SRTP_KMNGMNT_ZRTP = 1 << 4 ,
  RCE_SRTP_KMNGMNT_USER = 1 << 5 ,
  RCE_NO_H26X_PREPEND_SC = 1 << 6 ,
  RCE_H26X_DEPENDENCY_ENFORCEMENT = 1 << 7 ,
  RCE_FRAGMENT_GENERIC = 1 << 8 ,
  RCE_SYSTEM_CALL_CLUSTERING = 1 << 9 ,
  RCE_SRTP_NULL_CIPHER = 1 << 10 ,
  RCE_SRTP_AUTHENTICATE_RTP = 1 << 11 ,
  RCE_SRTP_REPLAY_PROTECTION = 1 << 12 ,
  RCE_RTCP = 1 << 13 ,
  RCE_HOLEPUNCH_KEEPALIVE = 1 << 14 ,
  RCE_SRTP_KEYSIZE_192 = 1 << 15 ,
  RCE_SRTP_KEYSIZE_256 = 1 << 16 ,
  RCE_ZRTP_DIFFIE_HELLMAN_MODE = 1 << 17 ,
  RCE_ZRTP_MULTISTREAM_MODE = 1 << 18 ,
  RCE_FRAME_RATE = 1 << 19 ,
  RCE_PACE_FRAGMENT_SENDING = 1 << 20 ,
  RCE_RTCP_MUX = 1 << 21
}
 RTP context enable flags. More...
 
enum  RTP_CTX_CONFIGURATION_FLAGS {
  RCC_UDP_RCV_BUF_SIZE = 1 ,
  RCC_UDP_SND_BUF_SIZE = 2 ,
  RCC_RING_BUFFER_SIZE = 3 ,
  RCC_PKT_MAX_DELAY = 4 ,
  RCC_DYN_PAYLOAD_TYPE = 5 ,
  RCC_CLOCK_RATE = 6 ,
  RCC_MTU_SIZE = 7 ,
  RCC_FPS_NUMERATOR = 8 ,
  RCC_FPS_DENOMINATOR = 9 ,
  RCC_SSRC = 10 ,
  RCC_REMOTE_SSRC = 11 ,
  RCC_SESSION_BANDWIDTH = 12 ,
  RCC_POLL_TIMEOUT = 13 ,
  RCC_MULTICAST_TTL = 15
}
 RTP context configuration flags. More...
 

Variables

thread_local rtp_error_t rtp_errno
 

Enumeration Type Documentation

◆ RTP_CTX_CONFIGURATION_FLAGS

RTP context configuration flags.

These flags are given to uvgrtp::media_stream::configure_ctx

Enumerator
RCC_UDP_RCV_BUF_SIZE 

How large is the receiver UDP buffer size

Default value is 4 MB

For video with high bitrate (100+ fps 4K), it is advisable to set this to a high number to prevent OS from dropping packets

RCC_UDP_SND_BUF_SIZE 

How large is the sender UDP buffer size

Default value is 4 MB

For video with high bitrate (100+ fps 4K), it is advisable to set this to a high number to prevent OS from dropping packets

RCC_RING_BUFFER_SIZE 

How large is the uvgRTP receiver ring buffer

Default value is 4 MB

For video with high bitrate (100+ fps 4K), it is advisable to set this to a high number to prevent uvgRTP from overwriting previous packets

RCC_PKT_MAX_DELAY 

How many milliseconds is each frame waited for until it is considered lost.

Default is 500 milliseconds

This is valid only for fragmented frames, i.e. RTP_FORMAT_H26X and RTP_FORMAT_GENERIC with RCE_FRAGMENT_GENERIC (TODO)

RCC_DYN_PAYLOAD_TYPE 

Change uvgRTP's default payload number in RTP header

RCC_CLOCK_RATE 

Change uvgRTP's clock rate in RTP header and RTP timestamp calculations

RCC_MTU_SIZE 

Set a maximum value for the Ethernet frame size assumed by uvgRTP.

Default is 1492, from this IP and UDP, and RTP headers are removed, giving a payload size of 1452 bytes.

If application wishes to use small UDP datagram, it can set MTU size to, for example, 500 bytes or if it wishes to use jumbo frames, it can set the MTU size to 9000 bytes

RCC_FPS_NUMERATOR 

Set the numerator of frame rate used by uvgRTP.

Default is 30.

Setting the fps for uvgRTP serves two possible functions:

1) if RCE_FRAME_RATE has been set, the fps is enforced and uvgRTP tries to send frames at this exact frame rate,

2) if RCE_PACE_FRAGMENT_SENDING has been set, the fragments are set at a constant pace spaced out evenly within frame interval

RCC_FPS_DENOMINATOR 

Set the denominator of frame rate used by uvgRTP.

Default is 1

See RCC_FPS_NUMERATOR for more info.

RCC_SSRC 

Set the local SSRC of the stream manually

By default local SSRC is generated randomly

RCC_REMOTE_SSRC 

Set the remote SSRC of the stream manually

By default remote SSRC is generated randomly

RCC_SESSION_BANDWIDTH 

Set bandwidth for the session

uvgRTP chooses this automatically depending on the format of the data being transferred. Use this flag to manually set the session bandwidth in kbps. RTCP reporting interval depends on this session bandwidth. The interval is calculated with the following formula:

RTCP interval = 1000 * 360 / session_bandwidth_kbps

Larger bandwidth values result in shorter RTCP intervals, and vice versa. See RFC 3550 Appendix A.7 for further information on RTCP interval

RCC_POLL_TIMEOUT 

Set the timeout value for socket polling

Default value is 100 ms. If you are experiencing packet loss when receiving, you can try lowering this value down to 0. This will, however cause increased CPU usage in the receiver, so use with caution.

RCC_MULTICAST_TTL 

Set the sender packets IP TTL (Time to Live) for multicast

Must be in range [1, 255]. Keep the system default if not set.

Definition at line 284 of file util.hh.

◆ RTP_CTX_ENABLE_FLAGS

RTP context enable flags.

These flags are passed to uvgrtp::session::create_stream and can be OR'ed together

Enumerator
RCE_NO_FLAGS 

Use this if you have no RCE flags.

RCE_SEND_ONLY 

address/port interpreted as remote, no binding to local socket

RCE_RECEIVE_ONLY 

address/port interpreted as local, sending not possible

RCE_SRTP 

Use SRTP for this connection

RCE_SRTP_KMNGMNT_ZRTP 

Use ZRTP for key management

If this flag is provided, before the session starts, ZRTP will negotiate keys with the remote participants and these keys are used as salting/keying material for the session.

This flag must be coupled with RCE_SRTP and is mutually exclusive with RCE_SRTP_KMNGMNT_USER.

RCE_SRTP_KMNGMNT_USER 

Use user-defined way to manage keys

If this flag is provided, before the media transportation starts, user must provide a master key and salt form which SRTP session keys are derived

This flag must be coupled with RCE_SRTP and is mutually exclusive with RCE_SRTP_KMNGMNT_ZRTP

RCE_NO_H26X_PREPEND_SC 

By default, uvgRTP restores the stream by prepending 3 or 4 byte start code to each received H26x frame, so there is no difference with sender input. You can remove start code prefix with this flag

RCE_H26X_DEPENDENCY_ENFORCEMENT 

Use this flag to discard inter frames that don't have their previous dependencies arrived. Does not work if the dependencies are not in monotonic order.

RCE_FRAGMENT_GENERIC 

Fragment frames into RTP packets of MTU size (1492 bytes).

Some RTP profiles define fragmentation by setting the marker bit indicating the last fragment of the frame. You can enable this functionality using this flag at both sender and receiver.

RCE_SYSTEM_CALL_CLUSTERING 

Enable System Call Clustering (SCC). Sender side flag.

The benefit of SCC is reduced CPU usage at the sender, but its cost is increased chance of losing frames at the receiving end due to too many packets arriving at once.

RCE_SRTP_NULL_CIPHER 

Disable RTP payload encryption

RCE_SRTP_AUTHENTICATE_RTP 

Enable RTP packet authentication

This flag forces the security layer to add authentication tag to each outgoing RTP packet for all streams that have SRTP enabled.

NOTE: this flag must be coupled with at least RCE_SRTP

RCE_SRTP_REPLAY_PROTECTION 

Enable packet replay protection

RCE_RTCP 

Enable RTCP for the media stream. If SRTP is enabled, SRTCP is used instead

RCE_HOLEPUNCH_KEEPALIVE 

If the Mediastream object is used as a unidirectional stream but holepunching has been enabled, this flag can be used to make uvgRTP periodically send a short UDP datagram to keep the hole in the firewall open

RCE_SRTP_KEYSIZE_192 

Use 192-bit keys with SRTP, only user key management is supported

RCE_SRTP_KEYSIZE_256 

Use 256-bit keys with SRTP, only user key management is supported

RCE_ZRTP_DIFFIE_HELLMAN_MODE 

Select which ZRTP stream performs the Diffie-Hellman exchange (default)

RCE_ZRTP_MULTISTREAM_MODE 

Select which ZRTP stream does not perform Diffie-Hellman exchange

RCE_FRAME_RATE 

Force uvgRTP to send packets at certain framerate (default 30 fps)

RCE_PACE_FRAGMENT_SENDING 

Paces the sending of frame fragments within frame interval (default 1/30 s)

RCE_RTCP_MUX 

Use a single UDP port for both RTP and RTCP transmission (default RTCP port is +1)

Definition at line 168 of file util.hh.

◆ RTP_ERROR

enum RTP_ERROR

RTP error codes.

These error valus are returned from various uvgRTP functions. Functions that return a pointer set rtp_errno global value that should be checked if a function call failed

Enumerator
RTP_OK 

Success.

RTP_GENERIC_ERROR 

Generic error condition.

RTP_SOCKET_ERROR 

Failed to create socket.

RTP_BIND_ERROR 

Failed to bind to interface.

RTP_INVALID_VALUE 

Invalid value.

RTP_SEND_ERROR 

System call send(2) or one of its derivatives failed.

RTP_MEMORY_ERROR 

Memory allocation failed.

RTP_SSRC_COLLISION 

SSRC collision detected.

RTP_INITIALIZED 

Object already initialized.

RTP_NOT_INITIALIZED 

Object has not been initialized.

RTP_NOT_SUPPORTED 

Method/version/extension not supported.

RTP_RECV_ERROR 

System call recv(2) or one of its derivatives failed.

RTP_TIMEOUT 

Operation timed out.

RTP_NOT_FOUND 

Object not found.

RTP_AUTH_TAG_MISMATCH 

Authentication tag does not match the RTP packet contents.

Definition at line 30 of file util.hh.

◆ RTP_FLAGS

enum RTP_FLAGS

These flags are given to uvgrtp::media_stream::push_frame() and they can be OR'ed together.

Enumerator
RTP_NO_FLAGS 

Use this if you have no RTP flags.

RTP_COPY 

Make a copy of the frame and perform operation on the copy. Cannot be used with unique_ptr.

RTP_NO_H26X_SCL 

By default, uvgRTP searches for start code prefixes (0x000001 or 0x00000001) from the frame to divide NAL units and remove the prefix. If you instead want to provide the NAL units without the start code prefix yourself, you may use this flag to disable Start Code Lookup (SCL) and the frames will be treated as send-ready NAL units.

RTP_H26X_DO_NOT_AGGR 

Disable the use of Aggregation Packets in H26x formats

Definition at line 137 of file util.hh.

◆ RTP_FORMAT

enum RTP_FORMAT

These flags are given to uvgrtp::session::create_stream()

Enumerator
RTP_FORMAT_GENERIC 

Same as PCMU.

RTP_FORMAT_PCMU 

PCMU, ITU-T G.711.

RTP_FORMAT_GSM 

GSM (Group Speciale Mobile)

RTP_FORMAT_G723 

G723.

RTP_FORMAT_DVI4_32 

DVI 32 kbit/s.

RTP_FORMAT_DVI4_64 

DVI 64 kbit/s.

RTP_FORMAT_LPC 

LPC.

RTP_FORMAT_PCMA 

PCMA.

RTP_FORMAT_G722 

G722.

RTP_FORMAT_L16_STEREO 

L16 Stereo.

RTP_FORMAT_L16_MONO 

L16 Mono.

RTP_FORMAT_G728 

G728.

RTP_FORMAT_DVI4_441 

DVI 44.1 kbit/s.

RTP_FORMAT_DVI4_882 

DVI 88.2 kbit/s.

RTP_FORMAT_G729 

G729, 8 kbit/s.

RTP_FORMAT_G726_40 

G726, 40 kbit/s.

RTP_FORMAT_G726_32 

G726, 32 kbit/s.

RTP_FORMAT_G726_24 

G726, 24 kbit/s.

RTP_FORMAT_G726_16 

G726, 16 kbit/s.

RTP_FORMAT_G729D 

G729D, 6.4 kbit/s.

RTP_FORMAT_G729E 

G729E, 11.8 kbit/s.

RTP_FORMAT_GSM_EFR 

GSM enhanced full rate speech transcoding.

RTP_FORMAT_L8 

L8, linear audio data samples.

RTP_FORMAT_VDVI 

VDVI, variable-rate DVI4.

RTP_FORMAT_OPUS 

Opus, see RFC 7587.

RTP_FORMAT_H264 

H.264/AVC, see RFC 6184.

RTP_FORMAT_H265 

H.265/HEVC, see RFC 7798.

RTP_FORMAT_H266 

H.266/VVC.

RTP_FORMAT_ATLAS 

V3C.

Definition at line 62 of file util.hh.