spandsp 3.0.0
sprt.h File Reference

Go to the source code of this file.

Classes

struct  channel_parms_t
 

Macros

#define SPRT_MIN_TC0_PAYLOAD_BYTES   140
 
#define SPRT_MAX_TC0_PAYLOAD_BYTES   256
 
#define SPRT_DEFAULT_TC0_PAYLOAD_BYTES   140
 
#define SPRT_MIN_TC1_PAYLOAD_BYTES   132
 
#define SPRT_MAX_TC1_PAYLOAD_BYTES   256
 
#define SPRT_DEFAULT_TC1_PAYLOAD_BYTES   132
 
#define SPRT_MIN_TC1_WINDOWS_SIZE   32
 
#define SPRT_MAX_TC1_WINDOWS_SIZE   96
 
#define SPRT_DEFAULT_TC1_WINDOWS_SIZE   32
 
#define SPRT_MIN_TC2_PAYLOAD_BYTES   132
 
#define SPRT_MAX_TC2_PAYLOAD_BYTES   256
 
#define SPRT_DEFAULT_TC2_PAYLOAD_BYTES   132
 
#define SPRT_MIN_TC2_WINDOWS_SIZE   8
 
#define SPRT_MAX_TC2_WINDOWS_SIZE   32
 
#define SPRT_DEFAULT_TC2_WINDOWS_SIZE   8
 
#define SPRT_MIN_TC3_PAYLOAD_BYTES   140
 
#define SPRT_MAX_TC3_PAYLOAD_BYTES   256
 
#define SPRT_DEFAULT_TC3_PAYLOAD_BYTES   140
 
#define SPRT_MAX_WINDOWS_SIZE   96
 
#define SPRT_DEFAULT_TIMER_TC1_TA01   90000 /* us */
 
#define SPRT_DEFAULT_TIMER_TC1_TA02   130000 /* us */
 
#define SPRT_DEFAULT_TIMER_TC1_TR03   500000 /* us */
 
#define SPRT_DEFAULT_TIMER_TC2_TA01   90000 /* us */
 
#define SPRT_DEFAULT_TIMER_TC2_TA02   500000 /* us */
 
#define SPRT_DEFAULT_TIMER_TC2_TR03   500000 /* us */
 
#define SPRT_MIN_MAX_TRIES   1
 
#define SPRT_MAX_MAX_TRIES   20
 
#define SPRT_DEFAULT_MAX_TRIES   10
 
#define SPRT_CHANNELS   4
 

Typedefs

typedef int(* sprt_tx_packet_handler_t) (void *user_data, const uint8_t pkt[], int len)
 
typedef int(* sprt_rx_delivery_handler_t) (void *user_data, int channel, int seq_no, const uint8_t msg[], int len)
 
typedef span_timestamp_t(* sprt_timer_handler_t) (void *user_data, span_timestamp_t timeout)
 
typedef struct sprt_state_s sprt_state_t
 

Enumerations

enum  sprt_status_e { SPRT_STATUS_OK = 0 , SPRT_STATUS_EXCESS_RETRIES = 1 , SPRT_STATUS_SUBSESSION_CHANGED = 2 , SPRT_STATUS_OUT_OF_SEQUENCE = 3 }
 
enum  sprt_tcid_range_view_e { SPRT_TCID_MIN = 0 , SPRT_TCID_MIN_RELIABLE = 1 , SPRT_TCID_MAX_RELIABLE = 2 , SPRT_TCID_MAX = 3 }
 
enum  sprt_tcid_e { SPRT_TCID_UNRELIABLE_UNSEQUENCED = 0 , SPRT_TCID_RELIABLE_SEQUENCED = 1 , SPRT_TCID_EXPEDITED_RELIABLE_SEQUENCED = 2 , SPRT_TCID_UNRELIABLE_SEQUENCED = 3 }
 
enum  sprt_timer_e { SPRT_TIMER_TA01 = 0 , SPRT_TIMER_TA02 = 1 , SPRT_TIMER_TR03 = 2 }
 
enum  sprt_timer_action_e { SPRT_TIMER_SET = 0 , SPRT_TIMER_CLEAR = 1 , SPRT_TIMER_ADJUST = 2 }
 

Functions

const char * sprt_transmission_channel_to_str (int channel)
 Find the name of an SPRT channel.
 
int sprt_timer_expired (sprt_state_t *s, span_timestamp_t now)
 
int sprt_rx_packet (sprt_state_t *s, const uint8_t pkt[], int len)
 Process a packet arriving from the far end. If the packet validates as an SPRT packet 0 is returned. If the packet does not follow the structure of an SPRT packet, or its packet type field does not contain the expected value, -1 is returned. In a mixed packet environment, where things like RTP, T.38 and SPRT packets are mixed in the same stream, -1 should indicate than one of the other packet sinks should be tried.
 
int sprt_tx (sprt_state_t *s, int channel, const uint8_t buf[], int len)
 Send a message to a SPRT channel.
 
int sprt_set_local_tc_windows_size (sprt_state_t *s, int channel, int size)
 
int sprt_get_local_tc_windows_size (sprt_state_t *s, int channel)
 
int sprt_set_local_tc_payload_bytes (sprt_state_t *s, int channel, int max_len)
 
int sprt_get_local_tc_payload_bytes (sprt_state_t *s, int channel)
 
int sprt_set_local_tc_max_tries (sprt_state_t *s, int channel, int max_tries)
 
int sprt_get_local_tc_max_tries (sprt_state_t *s, int channel)
 
int sprt_set_far_tc_payload_bytes (sprt_state_t *s, int channel, int max_len)
 
int sprt_get_far_tc_payload_bytes (sprt_state_t *s, int channel)
 
int sprt_set_far_tc_windows_size (sprt_state_t *s, int channel, int size)
 
int sprt_get_far_tc_windows_size (sprt_state_t *s, int channel)
 
int sprt_set_tc_timeout (sprt_state_t *s, int channel, int timer, int timeout)
 
int sprt_get_tc_timeout (sprt_state_t *s, int channel, int timer)
 
int sprt_set_local_busy (sprt_state_t *s, int channel, bool busy)
 Test if local end of SPRT context is busy.
 
bool sprt_get_far_busy_status (sprt_state_t *s, int channel)
 Test if far end of SPRT context is busy.
 
logging_state_tsprt_get_logging_state (sprt_state_t *s)
 Get the logging context associated with an SPRT context.
 
sprt_state_tsprt_init (sprt_state_t *s, uint8_t subsession_id, uint8_t rx_payload_type, uint8_t tx_payload_type, channel_parms_t parms[4], sprt_tx_packet_handler_t tx_packet_handler, void *tx_user_data, sprt_rx_delivery_handler_t rx_delivery_handler, void *rx_user_data, sprt_timer_handler_t timer_handler, void *timer_user_data, span_modem_status_func_t status_handler, void *status_user_data)
 Initialise an SPRT context.
 
int sprt_release (sprt_state_t *s)
 Release an SPRT context.
 
int sprt_free (sprt_state_t *s)
 Free an SPRT context.
 

Function Documentation

◆ sprt_free()

int sprt_free ( sprt_state_t * s)

Free an SPRT context.

Parameters
sThe SPRT context.
Returns
0 for OK.

References sprt_free(), and sprt_release().

Referenced by sprt_free().

◆ sprt_get_far_busy_status()

bool sprt_get_far_busy_status ( sprt_state_t * s,
int channel )

Test if far end of SPRT context is busy.

Test whether the far end of the specified channel of the SPRT context is currently busy.

Parameters
sThe SPRT context.
channelThe SPRT channel number.
Returns
true for busy

References sprt_get_far_busy_status().

Referenced by sprt_get_far_busy_status().

◆ sprt_get_logging_state()

logging_state_t * sprt_get_logging_state ( sprt_state_t * s)

Get the logging context associated with an SPRT context.

Get the logging context associated with an SPRT context.

Parameters
sThe SPRT context.
Returns
A pointer to the logging context

References sprt_state_s::logging, and sprt_get_logging_state().

Referenced by sprt_get_logging_state().

◆ sprt_init()

sprt_state_t * sprt_init ( sprt_state_t * s,
uint8_t subsession_id,
uint8_t rx_payload_type,
uint8_t tx_payload_type,
channel_parms_t parms[4],
sprt_tx_packet_handler_t tx_packet_handler,
void * tx_user_data,
sprt_rx_delivery_handler_t rx_delivery_handler,
void * rx_user_data,
sprt_timer_handler_t timer_handler,
void * timer_user_data,
span_modem_status_func_t status_handler,
void * status_user_data )

Initialise an SPRT context.

Parameters
sThe SPRT context.
subsession_idThe subsession ID for transmitted SPRT headers
rx_payload_typeThe payload type expected in received SPRT headers
tx_payload_typeThe payload type sent in transmitted SPRT headers
parmsThe parameter set for sizing the SPRT instance. NULL means use the defaults.
tx_packet_handlerThe callback function, used to send assembled packets.
tx_user_dataAn opaque pointer supplied to tx_packet_handler.
rx_delivery_handlerThe callback function, used to report arriving packets.
rx_user_dataAn opaque pointer supplied to rx_delivery_handler.
timer_handlerThe callback function, used to control the timers used by SPRT.
timer_user_dataAn opaque pointer supplied to timer_handler.
status_handlerThe callback function, used to report status events.
status_user_dataAn opaque pointer supplied to status_handler.
Returns
A pointer to the SPRT context, or NULL if there was a problem.

References sprt_state_s::logging, and sprt_init().

Referenced by sprt_init().

◆ sprt_release()

int sprt_release ( sprt_state_t * s)

Release an SPRT context.

Parameters
sThe SPRT context.
Returns
0 for OK.

References sprt_release().

Referenced by sprt_free(), and sprt_release().

◆ sprt_rx_packet()

int sprt_rx_packet ( sprt_state_t * s,
const uint8_t pkt[],
int len )

Process a packet arriving from the far end. If the packet validates as an SPRT packet 0 is returned. If the packet does not follow the structure of an SPRT packet, or its packet type field does not contain the expected value, -1 is returned. In a mixed packet environment, where things like RTP, T.38 and SPRT packets are mixed in the same stream, -1 should indicate than one of the other packet sinks should be tried.

Parameters
sThe SPRT context.
pktThe SPRT packet buffer.
lenThe length of the packet.
Returns
0 for accepted as a valid SPRT packet. -1 for rejected as an SPRT packet.

References sprt_state_s::logging, span_log(), span_log_buf(), and sprt_rx_packet().

Referenced by sprt_rx_packet().

◆ sprt_set_local_busy()

int sprt_set_local_busy ( sprt_state_t * s,
int channel,
bool busy )

Test if local end of SPRT context is busy.

Set whether the local end of the specified channel of the SPRT context is currently busy.

Parameters
sThe SPRT context.
channelThe SPRT channel number.
busytrue for busy.
Returns
true for previously busy

References sprt_set_local_busy().

Referenced by sprt_set_local_busy().

◆ sprt_transmission_channel_to_str()

const char * sprt_transmission_channel_to_str ( int channel)

Find the name of an SPRT channel.

Parameters
channelThe number of the SPRT channel (0 to 3).
Returns
A pointer to a short string name for the channel, or NULL for an invalid channel.

References sprt_transmission_channel_to_str().

Referenced by sprt_transmission_channel_to_str().

◆ sprt_tx()

int sprt_tx ( sprt_state_t * s,
int channel,
const uint8_t buf[],
int len )

Send a message to a SPRT channel.

Parameters
sThe SPRT context.
channelThe SPRT channel.
bufThe message.
lenThe length of the message.
Returns
0 for OK.

References sprt_state_s::logging, span_log(), and sprt_tx().

Referenced by sprt_tx().