uvgRTP 4.0.0
An open-source library for RTP/SRTP media delivery
Loading...
Searching...
No Matches
Core API

Available for both static and shared builds. Only ABI-safe fuctions and classes. More...

Classes

struct  uvgrtp::frame::rtp_frame
 See RFC 3550 section 5 More...
 
struct  uvgrtp::frame::rtcp_header
 Header for all RTCP packets defined in RFC 3550 section 6 More...
 
struct  uvgrtp::frame::rtcp_sender_info
 See RFC 3550 section 6.4.1 More...
 
struct  uvgrtp::frame::rtcp_report_block
 See RFC 3550 section 6.4.1 More...
 
struct  uvgrtp::frame::rtcp_sr
 See RFC 3550 section 6.4.1 More...
 
struct  uvgrtp::frame::rtcp_rr
 See RFC 3550 section 6.4.2 for details on the RTCP RR (Receiver Report). More...
 
struct  uvgrtp::frame::rtcp_sdes_item
 See RFC 3550 section 6.5 for details on RTCP SDES Item. More...
 
struct  uvgrtp::frame::rtcp_sdes_ck
 See RFC 3550 section 6.5 for details on RTCP SDES Chunk. More...
 
struct  uvgrtp::frame::rtcp_sdes
 See RFC 3550 section 6.5 for details on RTCP SDES (Source Description). More...
 
struct  uvgrtp::frame::rtcp_app_packet
 See RFC 3550 section 6.7 for details on RTCP Application Packet. More...
 

Functions

UVGRTP_EXPORT uint64_t uvgrtp::clock::ntp::now ()
 Get current time in NTP units.
 
UVGRTP_EXPORT uint64_t uvgrtp::clock::ntp::diff (uint64_t ntp1, uint64_t ntp2)
 Calculate the time difference of two NTP times.
 
UVGRTP_EXPORT uint64_t uvgrtp::clock::ntp::diff_now (uint64_t then)
 Calculate the time difference of two NTP times.
 
 uvgrtp::context::context ()
 RTP context constructor.
 
 uvgrtp::context::~context ()
 RTP context destructor.
 
sessionuvgrtp::context::create_session (const char *address)
 Create a new RTP session.
 
sessionuvgrtp::context::create_session (const char *local_address, const char *remote_address)
 Create a new RTP session between two IP addresses.
 
rtp_error_t uvgrtp::context::destroy_session (uvgrtp::session *session)
 Destroy RTP session and all of its media streams.
 
bool uvgrtp::context::crypto_enabled () const
 Has Crypto++ been included in uvgRTP library.
 
 uvgrtp::frame::__pragma (pack(push, 1)) struct UVGRTP_EXPORT rtp_header
 RTP header as defined in RFC 3550 (Section 5).
 
rtp_error_t UVGRTP_EXPORT uvgrtp::frame::dealloc_frame (uvgrtp::frame::rtp_frame *frame)
 Deallocates an RTP frame.
 
rtp_error_t UVGRTP_EXPORT uvgrtp::frame::dealloc_sr (uvgrtp::frame::rtcp_sr *sr)
 Deallocates an RTCP Sender Report (SR) frame.
 
rtp_error_t UVGRTP_EXPORT uvgrtp::frame::dealloc_rr (uvgrtp::frame::rtcp_rr *rr)
 Deallocates an RTCP Receiver Report (RR) frame.
 
rtp_error_t UVGRTP_EXPORT uvgrtp::frame::dealloc_sdes (uvgrtp::frame::rtcp_sdes *sdes)
 Deallocates an RTCP Source Description (SDES) frame.
 
rtp_error_t uvgrtp::media_stream::start_zrtp ()
 Start the ZRTP negotiation manually.
 
rtp_error_t uvgrtp::media_stream::add_srtp_ctx (uint8_t *key, uint8_t *salt)
 Add keying information for user-managed SRTP session.
 
rtp_error_t uvgrtp::media_stream::push_frame (uint8_t *data, size_t data_len, int rtp_flags)
 Send data to remote participant with a custom timestamp.
 
rtp_error_t uvgrtp::media_stream::push_frame (uint8_t *data, size_t data_len, uint32_t ts, int rtp_flags)
 Send data to remote participant with a custom timestamp.
 
rtp_error_t uvgrtp::media_stream::push_frame (uint8_t *data, size_t data_len, uint32_t ts, uint64_t ntp_ts, int rtp_flags)
 Send data to remote participant with custom RTP and NTP timestamps.
 
uvgrtp::frame::rtp_frameuvgrtp::media_stream::pull_frame ()
 Poll a frame indefinitely from the media stream object.
 
uvgrtp::frame::rtp_frameuvgrtp::media_stream::pull_frame (size_t timeout_ms)
 Poll a frame for a specified time from the media stream object.
 
rtp_error_t uvgrtp::media_stream::install_receive_hook (void *arg, void(*hook)(void *, uvgrtp::frame::rtp_frame *))
 Asynchronous way of getting frames.
 
rtp_error_t uvgrtp::media_stream::configure_ctx (int rcc_flag, ssize_t value)
 Configure the media stream, see RTP_CTX_CONFIGURATION_FLAGS for more details.
 
int uvgrtp::media_stream::get_configuration_value (int rcc_flag)
 Get the values associated with configuration flags, see RTP_CTX_CONFIGURATION_FLAGS for more details.
 
uvgrtp::rtcpuvgrtp::media_stream::get_rtcp ()
 Get pointer to the RTCP object of the media stream.
 
uint32_t uvgrtp::media_stream::get_ssrc () const
 Get SSRC identifier. You can use the SSRC value for example to find the report block belonging to this media stream in RTCP sender/receiver report.
 
void uvgrtp::rtcp::set_ts_info (uint64_t clock_start, uint32_t clock_rate, uint32_t rtp_ts_start)
 Provide timestamping information for RTCP.
 
rtp_error_t uvgrtp::rtcp::add_sdes_item (const uvgrtp::frame::rtcp_sdes_item &item)
 Add an SDES item that will be included in all future RTCP SDES packets.
 
rtp_error_t uvgrtp::rtcp::clear_sdes_items ()
 Remove all SDES items previously added with add_sdes_item()
 
rtp_error_t uvgrtp::rtcp::send_app_packet (const char *name, uint8_t subtype, uint32_t payload_len, const uint8_t *payload)
 Send an RTCP APP packet.
 
rtp_error_t uvgrtp::rtcp::install_send_app_hook (const char *app_name, uint8_t *(*send_hook)(uint8_t *subtype, uint32_t *payload_len, void *user_arg), void *user_arg)
 Install a hook for generating RTCP APP packets during RTCP reporting.
 
rtp_error_t uvgrtp::rtcp::remove_send_app_hook (const char *app_name)
 Remove a previously installed APP sending hook.
 
rtp_error_t uvgrtp::rtcp::send_bye_packet (const uint32_t *ssrcs, size_t count)
 Send an RTCP BYE packet to indicate stream end.
 
rtp_error_t uvgrtp::rtcp::install_sender_hook (void(*handler)(uvgrtp::frame::rtcp_sr *))
 Install a callback for incoming RTCP Sender Reports.
 
rtp_error_t uvgrtp::rtcp::install_receiver_hook (void(*handler)(uvgrtp::frame::rtcp_rr *))
 Install a callback for incoming RTCP Receiver Reports.
 
rtp_error_t uvgrtp::rtcp::install_sdes_hook (void(*handler)(uvgrtp::frame::rtcp_sdes *))
 Install a callback for incoming RTCP SDES packets.
 
rtp_error_t uvgrtp::rtcp::install_app_hook (void(*handler)(uvgrtp::frame::rtcp_app_packet *))
 Install a callback for incoming RTCP APP packets.
 
rtp_error_t uvgrtp::rtcp::remove_all_hooks ()
 Remove all installed reception RTCP packet hook, but not app send hook.
 
uvgrtp::frame::rtcp_sruvgrtp::rtcp::get_sr (uint32_t ssrc)
 Get sender report for given SSRC.
 
uvgrtp::frame::rtcp_rruvgrtp::rtcp::get_rr (uint32_t ssrc)
 Get receiver report for given SSRC.
 
uvgrtp::frame::rtcp_sdesuvgrtp::rtcp::get_sdes (uint32_t ssrc)
 Get SDES packet for given SSRC.
 
uvgrtp::frame::rtcp_app_packetuvgrtp::rtcp::get_app_packet (uint32_t ssrc)
 Get APP packet for given SSRC.
 
uvgrtp::media_streamuvgrtp::session::create_stream (uint16_t src_port, uint16_t dst_port, rtp_format_t fmt, int rce_flags)
 Create a uni- or bidirectional media stream.
 
uvgrtp::media_streamuvgrtp::session::create_stream (uint16_t port, rtp_format_t fmt, int rce_flags)
 Create a unidirectional media_stream for an RTP session.
 
rtp_error_t uvgrtp::session::destroy_stream (uvgrtp::media_stream *stream)
 Destroy a media stream.
 
uint16_t UVGRTP_EXPORT uvgrtp::get_version_major ()
 Get the major version number of uvgRTP.
 
uint16_t UVGRTP_EXPORT uvgrtp::get_version_minor ()
 Get the minor version number of uvgRTP.
 
uint16_t UVGRTP_EXPORT uvgrtp::get_version_patch ()
 Get the patch version number of uvgRTP.
 
const char *UVGRTP_EXPORT uvgrtp::get_version_cstr ()
 Get the full version string of uvgRTP as a C string.
 
const char *UVGRTP_EXPORT uvgrtp::get_git_hash_cstr ()
 Get the Git commit hash of the uvgRTP build as a C string.
 

Detailed Description

Available for both static and shared builds. Only ABI-safe fuctions and classes.

Function Documentation

◆ __pragma()

uvgrtp::frame::__pragma ( pack(push, 1) )

RTP header as defined in RFC 3550 (Section 5).

RTP extension header.

See also
https://www.rfc-editor.org/rfc/rfc3550#section-5

The RTP header contains fields that define the basic structure of the RTP packet, including version, padding, payload type, sequence number, timestamp, and synchronization source identifier (SSRC).

See also
https://www.rfc-editor.org/rfc/rfc3550#section-5.3

The extension header provides additional information for the RTP packet, such as the type of extension and the length of the extension data.

< RTP version (2 bits)

< Padding flag (1 bit)

< Extension header flag (1 bit)

< CSRC count (4 bits)

< Marker bit (1 bit)

< Payload type (7 bits)

< Sequence number (16 bits)

< Timestamp (32 bits)

< Synchronization source identifier (SSRC) (32 bits)

Definition at line 66 of file frame.hh.

◆ add_sdes_item()

rtp_error_t uvgrtp::rtcp::add_sdes_item ( const uvgrtp::frame::rtcp_sdes_item & item)

Add an SDES item that will be included in all future RTCP SDES packets.

Parameters
itemSDES item to include (C-compatible ABI-safe struct)
Return values
RTP_OKon success
RTP_GENERIC_ERRORon failure

◆ add_srtp_ctx()

rtp_error_t uvgrtp::media_stream::add_srtp_ctx ( uint8_t * key,
uint8_t * salt )

Add keying information for user-managed SRTP session.

For user-managed SRTP session (flag RCE_SRTP_KMNGMNT_USER), the media stream is not started until SRTP key has been added and all calls to push_frame() will fail.

Parameters
keySRTP master key, default is 128-bit long
salt112-bit long salt
Returns
RTP error code
Return values
RTP_OKOn success
RTP_INVALID_VALUEIf key or salt is invalid
RTP_NOT_SUPPORTEDIf user-managed SRTP was not specified in create_stream()

◆ clear_sdes_items()

rtp_error_t uvgrtp::rtcp::clear_sdes_items ( )

Remove all SDES items previously added with add_sdes_item()

Clears the list of SDES items that are included in outgoing RTCP SDES packets.

Return values
RTP_OKon success

◆ configure_ctx()

rtp_error_t uvgrtp::media_stream::configure_ctx ( int rcc_flag,
ssize_t value )

Configure the media stream, see RTP_CTX_CONFIGURATION_FLAGS for more details.

Returns
RTP error code
Return values
RTP_OKOn success
RTP_INVALID_VALUEIf the provided value is not valid for a given configuration flag
RTP_GENERIC_ERRORIf setsockopt(2) failed

◆ context()

uvgrtp::context::context ( )

RTP context constructor.

Most of the time one RTP context per application is enough. If CNAME namespace isolation is required, multiple context objects can be created.

◆ create_session() [1/2]

session * uvgrtp::context::create_session ( const char * address)

Create a new RTP session.

Parameters
addressIP address of remote or local participant
Returns
RTP session object
Return values
uvgrtp::sessionOn success
nullptrIf "address" is empty or memory allocation failed

◆ create_session() [2/2]

session * uvgrtp::context::create_session ( const char * local_address,
const char * remote_address )

Create a new RTP session between two IP addresses.

Parameters
local_addressLocal IP address for the session
remote_addressRemote IP address for the session
Returns
RTP session object
Return values
uvgrtp::sessionOn success
nullptrIf memory allocation failed

◆ create_stream() [1/2]

uvgrtp::media_stream * uvgrtp::session::create_stream ( uint16_t port,
rtp_format_t fmt,
int rce_flags )

Create a unidirectional media_stream for an RTP session.

The created object is used for sending or receiving media, see documentation for uvgrtp::media_stream for more details.

User can enable and disable functionality of uvgRTP by OR'ing (using |) RCE_* flags together and passing them using the rce_flags parameter. The RCE_SEND_ONLY flag in rce_flags means the port is interpreted as a remote port. The RCE_RECEIVE_ONLY means the port is used for binding to a local interface. Without either flag, this function defaults to RCE_SEND_ONLY.

Parameters
portEither local or remote port depending on rce_flags
fmtFormat of the media stream. see RTP_FORMAT for more details
rce_flagsRTP context enable flags, see RTP_CTX_ENABLE_FLAGS for more details
Returns
RTP media stream object
Return values
uvgrtp::media_stream*On success
nullptrOn failure, see print

◆ create_stream() [2/2]

uvgrtp::media_stream * uvgrtp::session::create_stream ( uint16_t src_port,
uint16_t dst_port,
rtp_format_t fmt,
int rce_flags )

Create a uni- or bidirectional media stream.

The created object is used for sending and/or receiving media, see documentation for uvgrtp::media_stream for more details.

If both addresses were provided when uvgrtp::session was created, by default uvgRTP binds itself to local_addr:src_port and sends packets to remote_addr:dst_port.

User can enable and disable functionality of media_stream by OR'ing (using |) RCE_* flags together and passing them using the rce_flags parameter. In rce_flags, the RCE_SEND_ONLY flag can be used to avoid binding and src_port is thus ignored. Correspondinly RCE_RECEIVE_ONLY flag means dst_port is ignored. Without either RCE_SEND_ONLY or RCE_RECEIVE_ONLY, and if only one address was provided for session that address is interpreted as remote_addr and binding happens to ANY:src_port.

Parameters
src_portLocal port that uvgRTP listens to for incoming RTP packets
dst_portRemote port where uvgRTP sends RTP packets
fmtFormat of the media stream. see RTP_FORMAT for more details
rce_flagsRTP context enable flags, see RTP_CTX_ENABLE_FLAGS for more details

If no explicit SSRC is provided during creation, the stream will be assigned a random non-zero SSRC internally. To set an explicit SSRC, call configure_ctx(RCC_SSRC, value) on the returned uvgrtp::media_stream.

Returns
RTP media stream object
Return values
uvgrtp::media_stream*On success
nullptrOn failure, see print and

◆ crypto_enabled()

bool uvgrtp::context::crypto_enabled ( ) const

Has Crypto++ been included in uvgRTP library.

Return values
trueCrypto++ has been included, using SRTP is possible
falseCrypto++ has not been included, using SRTP is not possible

◆ dealloc_frame()

rtp_error_t UVGRTP_EXPORT uvgrtp::frame::dealloc_frame ( uvgrtp::frame::rtp_frame * frame)

Deallocates an RTP frame.

This function is responsible for deallocating an RTP frame object.

Parameters
framePointer to the RTP frame to be deallocated.
Returns
RTP_OK on success.
RTP_INVALID_VALUE if the provided "frame" is nullptr.

◆ dealloc_rr()

rtp_error_t UVGRTP_EXPORT uvgrtp::frame::dealloc_rr ( uvgrtp::frame::rtcp_rr * rr)

Deallocates an RTCP Receiver Report (RR) frame.

This function is responsible for deallocating an RTCP Receiver Report (RR) frame object.

Parameters
rrPointer to the RTCP RR frame to be deallocated.
Returns
RTP_OK on success.
RTP_INVALID_VALUE if the provided "rr" is nullptr.

◆ dealloc_sdes()

rtp_error_t UVGRTP_EXPORT uvgrtp::frame::dealloc_sdes ( uvgrtp::frame::rtcp_sdes * sdes)

Deallocates an RTCP Source Description (SDES) frame.

This function is responsible for deallocating an RTCP Source Description (SDES) frame object.

Parameters
sdesPointer to the RTCP SDES frame to be deallocated.
Returns
RTP_OK on success.
RTP_INVALID_VALUE if the provided "sdes" is nullptr.

◆ dealloc_sr()

rtp_error_t UVGRTP_EXPORT uvgrtp::frame::dealloc_sr ( uvgrtp::frame::rtcp_sr * sr)

Deallocates an RTCP Sender Report (SR) frame.

This function is responsible for deallocating an RTCP Sender Report (SR) frame object.

Parameters
srPointer to the RTCP SR frame to be deallocated.
Returns
RTP_OK on success.
RTP_INVALID_VALUE if the provided "sr" is nullptr.

◆ destroy_session()

rtp_error_t uvgrtp::context::destroy_session ( uvgrtp::session * session)

Destroy RTP session and all of its media streams.

Parameters
sessionPointer to the session object that should be destroyed
Returns
RTP error code
Return values
RTP_OKOn success
RTP_INVALID_VALUEIf session is nullptr

◆ destroy_stream()

rtp_error_t uvgrtp::session::destroy_stream ( uvgrtp::media_stream * stream)

Destroy a media stream.

Parameters
streamPointer to the media stream that should be destroyed
Returns
RTP error code
Return values
RTP_OKOn success
RTP_INVALID_VALUEIf stream is nullptr
RTP_NOT_FOUNDIf stream does not belong to this session

◆ diff()

UVGRTP_EXPORT uint64_t uvgrtp::clock::ntp::diff ( uint64_t ntp1,
uint64_t ntp2 )

Calculate the time difference of two NTP times.

The second timestamp is subtracted from the first one

Parameters
ntp1First NTP timestamp
ntp2Second NTP timestamp
Returns
Difference of the timestamps in milliseconds

◆ diff_now()

UVGRTP_EXPORT uint64_t uvgrtp::clock::ntp::diff_now ( uint64_t then)

Calculate the time difference of two NTP times.

This function calls uvgrtp::clock::ntp::now() and then subtracts the input parameter from that timestamp value.

Parameters
thenNTP timestamp
Returns
Difference of the timestamps in milliseconds

◆ get_app_packet()

uvgrtp::frame::rtcp_app_packet * uvgrtp::rtcp::get_app_packet ( uint32_t ssrc)

Get APP packet for given SSRC.

Parameters
ssrcSSRC identifier to lookup
Return values
pointerto rtcp_app_packet if found, nullptr otherwise

◆ get_configuration_value()

int uvgrtp::media_stream::get_configuration_value ( int rcc_flag)

Get the values associated with configuration flags, see RTP_CTX_CONFIGURATION_FLAGS for more details.

Returns
Value of the configuration flag
Return values
intvalue on success
-1on error

◆ get_git_hash_cstr()

const char *UVGRTP_EXPORT uvgrtp::get_git_hash_cstr ( )

Get the Git commit hash of the uvgRTP build as a C string.

Returns
Pointer to a null-terminated git-hash string (lifetime: static)

◆ get_rr()

uvgrtp::frame::rtcp_rr * uvgrtp::rtcp::get_rr ( uint32_t ssrc)

Get receiver report for given SSRC.

Parameters
ssrcSSRC identifier to lookup
Return values
pointerto rtcp_rr if found, nullptr otherwise

◆ get_rtcp()

uvgrtp::rtcp * uvgrtp::media_stream::get_rtcp ( )

Get pointer to the RTCP object of the media stream.

This object is used to control all RTCP-related functionality and RTCP documentation can be found in uvgrtp::rtcp

Returns
Pointer to RTCP object
Return values
uvgrtp::rtcp*If RTCP has been enabled (RCE_RTCP has been given to uvgrtp::session::create_stream())
nullptrIf RTCP has not been enabled

◆ get_sdes()

uvgrtp::frame::rtcp_sdes * uvgrtp::rtcp::get_sdes ( uint32_t ssrc)

Get SDES packet for given SSRC.

Parameters
ssrcSSRC identifier to lookup
Return values
pointerto rtcp_sdes if found, nullptr otherwise

◆ get_sr()

uvgrtp::frame::rtcp_sr * uvgrtp::rtcp::get_sr ( uint32_t ssrc)

Get sender report for given SSRC.

Parameters
ssrcSSRC identifier to lookup
Return values
pointerto rtcp_sr if found, nullptr otherwise

◆ get_ssrc()

uint32_t uvgrtp::media_stream::get_ssrc ( ) const

Get SSRC identifier. You can use the SSRC value for example to find the report block belonging to this media stream in RTCP sender/receiver report.

Returns
SSRC value

◆ get_version_cstr()

const char *UVGRTP_EXPORT uvgrtp::get_version_cstr ( )

Get the full version string of uvgRTP as a C string.

Returns
Pointer to a null-terminated version string (lifetime: static)

◆ get_version_major()

uint16_t UVGRTP_EXPORT uvgrtp::get_version_major ( )

Get the major version number of uvgRTP.

Returns
Major version number.

◆ get_version_minor()

uint16_t UVGRTP_EXPORT uvgrtp::get_version_minor ( )

Get the minor version number of uvgRTP.

Returns
Minor version number.

◆ get_version_patch()

uint16_t UVGRTP_EXPORT uvgrtp::get_version_patch ( )

Get the patch version number of uvgRTP.

Returns
Patch version number.

◆ install_app_hook()

rtp_error_t uvgrtp::rtcp::install_app_hook ( void(* handler )(uvgrtp::frame::rtcp_app_packet *))

Install a callback for incoming RTCP APP packets.

Parameters
handlerFunction to call when an APP packet is received
Return values
RTP_OKon success
RTP_INVALID_VALUEif handler is nullptr

◆ install_receive_hook()

rtp_error_t uvgrtp::media_stream::install_receive_hook ( void * arg,
void(* hook )(void *, uvgrtp::frame::rtp_frame *) )

Asynchronous way of getting frames.

The receive hook is an alternative to polling frames using uvgrtp::media_stream::pull_frame(). Instead of the application asking from uvgRTP if there are any new frames available, uvgRTP will notify the application when a frame has been received.

The hook should not be used for media processing as it will block the receiver from reading more frames. Instead, it should only be used as an interface between uvgRTP and the calling application where the frame hand-off happens.

Parameters
argOptional argument that is passed to the hook when it is called, can be set to nullptr
hookFunction pointer to the receive hook that uvgRTP should call
Returns
RTP error code
Return values
RTP_OKOn success
RTP_INVALID_VALUEIf hook is nullptr

◆ install_receiver_hook()

rtp_error_t uvgrtp::rtcp::install_receiver_hook ( void(* handler )(uvgrtp::frame::rtcp_rr *))

Install a callback for incoming RTCP Receiver Reports.

Parameters
handlerFunction to call when a Receiver Report is received
Return values
RTP_OKon success
RTP_INVALID_VALUEif handler is nullptr

◆ install_sdes_hook()

rtp_error_t uvgrtp::rtcp::install_sdes_hook ( void(* handler )(uvgrtp::frame::rtcp_sdes *))

Install a callback for incoming RTCP SDES packets.

Parameters
handlerFunction to call when an SDES packet is received
Return values
RTP_OKon success
RTP_INVALID_VALUEif handler is nullptr

◆ install_send_app_hook()

rtp_error_t uvgrtp::rtcp::install_send_app_hook ( const char * app_name,
uint8_t *(* send_hook )(uint8_t *subtype, uint32_t *payload_len, void *user_arg),
void * user_arg )

Install a hook for generating RTCP APP packets during RTCP reporting.

This function installs a C-style callback that is called every time RTCP packets are being prepared for sending. The callback is responsible for returning a pointer to the payload data and filling in subtype and length. The returned buffer must be allocated on the heap using new uint8_t[] and will be freed by uvgRTP.

Parameters
app_nameName of the APP item, must be 4 ASCII characters
send_hookFunction pointer for the hook
user_argUser-provided pointer passed to the callback
Return values
RTP_OKOn success
RTP_INVALID_VALUEIf input is invalid

◆ install_sender_hook()

rtp_error_t uvgrtp::rtcp::install_sender_hook ( void(* handler )(uvgrtp::frame::rtcp_sr *))

Install a callback for incoming RTCP Sender Reports.

Parameters
handlerFunction to call when a Sender Report is received
Return values
RTP_OKon success
RTP_INVALID_VALUEif handler is nullptr

◆ now()

UVGRTP_EXPORT uint64_t uvgrtp::clock::ntp::now ( )

Get current time in NTP units.

Returns
NTP timestamp

◆ pull_frame() [1/2]

uvgrtp::frame::rtp_frame * uvgrtp::media_stream::pull_frame ( )

Poll a frame indefinitely from the media stream object.

Returns
RTP frame
Return values
uvgrtp::frame::rtp_frame*On success
nullptrIf an unrecoverable error occurred

◆ pull_frame() [2/2]

uvgrtp::frame::rtp_frame * uvgrtp::media_stream::pull_frame ( size_t timeout_ms)

Poll a frame for a specified time from the media stream object.

Parameters
timeout_msHow long to wait for a frame, in milliseconds
Returns
RTP frame
Return values
uvgrtp::frame::rtp_frame*On success
nullptrIf a frame was not received within the specified time limit or in case of an error

◆ push_frame() [1/3]

rtp_error_t uvgrtp::media_stream::push_frame ( uint8_t * data,
size_t data_len,
int rtp_flags )

Send data to remote participant with a custom timestamp.

If so specified either by the selected media format and/or given RTP_CTX_ENABLE_FLAGS, uvgRTP fragments the input data into RTP packets of 1492 bytes, or to any other size defined by the application using RCC_MTU_SIZE.

The frame is automatically reconstructed by the receiver if all fragments have been received successfully.

Parameters
dataPointer to data that should be sent, uvgRTP does not take ownership of the memory
data_lenLength of data
rtp_flagsOptional flags, see RTP_FLAGS for more details
Returns
RTP error code
Return values
RTP_OKOn success
RTP_INVALID_VALUEIf one of the parameters is invalid
RTP_MEMORY_ERRORIf the data chunk is too large to be processed
RTP_SEND_ERRORIf uvgRTP failed to send the data to remote
RTP_GENERIC_ERRORIf an unspecified error occurred

◆ push_frame() [2/3]

rtp_error_t uvgrtp::media_stream::push_frame ( uint8_t * data,
size_t data_len,
uint32_t ts,
int rtp_flags )

Send data to remote participant with a custom timestamp.

If so specified either by the selected media format and/or given RTP_CTX_ENABLE_FLAGS, uvgRTP fragments the input data into RTP packets of 1492 bytes, or to any other size defined by the application using RCC_MTU_SIZE.

The frame is automatically reconstructed by the receiver if all fragments have been received successfully.

If the application wishes, it may override uvgRTP's own timestamp calculations and provide timestamping information for the stream itself. This requires that the application provides a sensible value for the ts parameter. If RTCP has been enabled, uvgrtp::rtcp::set_ts_info() should have been called.

Parameters
dataPointer to data that should be sent, uvgRTP does not take ownership of the memory
data_lenLength of data
ts32-bit timestamp value for the data
rtp_flagsOptional flags, see RTP_FLAGS for more details
Returns
RTP error code
Return values
RTP_OKOn success
RTP_INVALID_VALUEIf one of the parameters is invalid
RTP_MEMORY_ERRORIf the data chunk is too large to be processed
RTP_SEND_ERRORIf uvgRTP failed to send the data to remote
RTP_GENERIC_ERRORIf an unspecified error occurred

◆ push_frame() [3/3]

rtp_error_t uvgrtp::media_stream::push_frame ( uint8_t * data,
size_t data_len,
uint32_t ts,
uint64_t ntp_ts,
int rtp_flags )

Send data to remote participant with custom RTP and NTP timestamps.

If so specified either by the selected media format and/or given RTP_CTX_ENABLE_FLAGS, uvgRTP fragments the input data into RTP packets of 1492 bytes, or to any other size defined by the application using RCC_MTU_SIZE.

The frame is automatically reconstructed by the receiver if all fragments have been received successfully.

If the application wishes, it may override uvgRTP's own timestamp calculations and provide timestamping information for the stream itself. This requires that the application provides a sensible value for the ts parameter. If RTCP has been enabled, uvgrtp::rtcp::set_ts_info() should have been called.

Parameters
dataPointer to data that should be sent, uvgRTP does not take ownership of the memory
data_lenLength of data
ts32-bit RTP timestamp for the packet
ntp_ts64-bit NTP timestamp value of when the packet's data was sampled. NTP timestamp is a 64-bit unsigned fixed-point number with the integer part (seconds) in the first 32 bits and the fractional part (fractional seconds) in the last 32 bits. Used for synchronizing multiple streams.
rtp_flagsOptional flags, see RTP_FLAGS for more details
Returns
RTP error code
Return values
RTP_OKOn success
RTP_INVALID_VALUEIf one of the parameters is invalid
RTP_MEMORY_ERRORIf the data chunk is too large to be processed
RTP_SEND_ERRORIf uvgRTP failed to send the data to remote
RTP_GENERIC_ERRORIf an unspecified error occurred

◆ remove_all_hooks()

rtp_error_t uvgrtp::rtcp::remove_all_hooks ( )

Remove all installed reception RTCP packet hook, but not app send hook.

Return values
RTP_OKon success

◆ remove_send_app_hook()

rtp_error_t uvgrtp::rtcp::remove_send_app_hook ( const char * app_name)

Remove a previously installed APP sending hook.

Parameters
app_nameFour-character name of the APP hook to remove
Return values
RTP_OKon success
RTP_NOT_FOUNDif hook was not found

◆ send_app_packet()

rtp_error_t uvgrtp::rtcp::send_app_packet ( const char * name,
uint8_t subtype,
uint32_t payload_len,
const uint8_t * payload )

Send an RTCP APP packet.

Parameters
nameFour-character name of the APP packet (e.g., "STAT")
subtypeSubtype (0-31) for the APP message
payload_lenSize of payload in bytes
payloadPointer to payload data
Return values
RTP_OKon success
RTP_MEMORY_ERRORif allocation fails
RTP_GENERIC_ERRORif sending fails

◆ send_bye_packet()

rtp_error_t uvgrtp::rtcp::send_bye_packet ( const uint32_t * ssrcs,
size_t count )

Send an RTCP BYE packet to indicate stream end.

Parameters
ssrcsArray of SSRCs to include in the BYE
countNumber of SSRCs in the array
Return values
RTP_OKon success
RTP_INVALID_VALUEon invalid parameters

◆ set_ts_info()

void uvgrtp::rtcp::set_ts_info ( uint64_t clock_start,
uint32_t clock_rate,
uint32_t rtp_ts_start )

Provide timestamping information for RTCP.

If the application wishes to timestamp the stream itself and it has enabled RTCP (via RCE_RTCP), it should provide timestamping information for RTCP so sensible synchronization values can be calculated for Sender Reports.

You can use uvgrtp::clock::ntp::now() to get the current NTP timestamp.

Parameters
clock_startNTP timestamp at t = 0
clock_rateClock rate of the media (Hz)
rtp_ts_startRTP timestamp at t = 0

◆ start_zrtp()

rtp_error_t uvgrtp::media_stream::start_zrtp ( )

Start the ZRTP negotiation manually.

There are two ways to use ZRTP:

  1. Use flags RCE_SRTP + RCE_SRTP_KMNGMNT_ZRTP + (RCE_ZRTP_DIFFIE_HELLMAN_MODE/RCE_ZRTP_MULTISTREAM_MODE) to automatically start ZRTP negotiation when creating a media stream.
  2. Use flags RCE_SRTP + (RCE_ZRTP_DIFFIE_HELLMAN_MODE/RCE_ZRTP_MULTISTREAM_MODE) and after creating the media stream, call start_zrtp() to manually start the ZRTP negotiation.
Returns
RTP error code
Return values
RTP_OKOn success
RTP_TIMEOUTIf ZRTP timed out
RTP_GENERIC_ERROROn other errors

◆ ~context()

uvgrtp::context::~context ( )

RTP context destructor.

This does not destroy active sessions. They must be destroyed manually by calling uvgrtp::context::destroy_session()