Group PJSUA_LIB_TRANSPORT

group PJSUA_LIB_TRANSPORT

API for managing SIP transports.

PJSUA-API supports creating multiple transport instances, for example UDP, TCP, and TLS transport. SIP transport must be created before adding an account.

Typedefs

typedef int pjsua_transport_id

SIP transport identification.

Functions

void pjsua_transport_config_default(pjsua_transport_config *cfg)

Call this function to initialize UDP config with default values.

Parameters

cfg – The UDP config to be initialized.

void pjsua_transport_config_dup(pj_pool_t *pool, pjsua_transport_config *dst, const pjsua_transport_config *src)

Duplicate transport config.

Parameters
  • pool – The pool.

  • dst – The destination config.

  • src – The source config.

pj_status_t pjsua_transport_create(pjsip_transport_type_e type, const pjsua_transport_config *cfg, pjsua_transport_id *p_id)

Create and start a new SIP transport according to the specified settings.

Parameters
  • type – Transport type.

  • cfg – Transport configuration.

  • p_id – Optional pointer to receive transport ID.

Returns

PJ_SUCCESS on success, or the appropriate error code.

pj_status_t pjsua_transport_register(pjsip_transport *tp, pjsua_transport_id *p_id)

Register transport that has been created by application. This function is useful if application wants to implement custom SIP transport and use it with pjsua.

Parameters
  • tp – Transport instance.

  • p_id – Optional pointer to receive transport ID.

Returns

PJ_SUCCESS on success, or the appropriate error code.

pj_status_t pjsua_enum_transports(pjsua_transport_id id[], unsigned *count)

Enumerate all transports currently created in the system. This function will return all transport IDs, and application may then call pjsua_transport_get_info() function to retrieve detailed information about the transport.

Parameters
  • id – Array to receive transport ids.

  • count – In input, specifies the maximum number of elements. On return, it contains the actual number of elements.

Returns

PJ_SUCCESS on success, or the appropriate error code.

pj_status_t pjsua_transport_get_info(pjsua_transport_id id, pjsua_transport_info *info)

Get information about transports.

Parameters
  • id – Transport ID.

  • info – Pointer to receive transport info.

Returns

PJ_SUCCESS on success, or the appropriate error code.

pj_status_t pjsua_transport_set_enable(pjsua_transport_id id, pj_bool_t enabled)

Disable a transport or re-enable it. By default transport is always enabled after it is created. Disabling a transport does not necessarily close the socket, it will only discard incoming messages and prevent the transport from being used to send outgoing messages.

Parameters
  • id – Transport ID.

  • enabled – Non-zero to enable, zero to disable.

Returns

PJ_SUCCESS on success, or the appropriate error code.

pj_status_t pjsua_transport_close(pjsua_transport_id id, pj_bool_t force)

Close the transport. If transport is forcefully closed, it will be immediately closed, and any pending transactions that are using the transport may not terminate properly (it may even crash). Otherwise, the system will wait until all transactions are closed while preventing new users from using the transport, and will close the transport when it is safe to do so.

Parameters
  • id – Transport ID.

  • force – Non-zero to immediately close the transport. This is not recommended!

Returns

PJ_SUCCESS on success, or the appropriate error code.

struct pjsua_transport_config
#include <pjsua.h>

Transport configuration for creating transports for both SIP and media. Before setting some values to this structure, application MUST call pjsua_transport_config_default() to initialize its values with default settings.

struct pjsua_transport_info
#include <pjsua.h>

This structure describes transport information returned by pjsua_transport_get_info() function.