|
ascii-chat 0.6.0
Real-time terminal-based video chat with ASCII art conversion
|
ICE candidate gathering and exchange. More...
Go to the source code of this file.
Functions | |
| const char * | ice_candidate_type_name (ice_candidate_type_t type) |
| Get human-readable candidate type name. | |
| const char * | ice_protocol_name (ice_protocol_t protocol) |
| Get human-readable protocol name. | |
| uint32_t | ice_calculate_priority (ice_candidate_type_t type, uint16_t local_preference, uint8_t component_id) |
| Calculate candidate priority. | |
| asciichat_error_t | ice_parse_candidate (const char *line, ice_candidate_t *candidate) |
| Parse ICE candidate from attribute string. | |
| asciichat_error_t | ice_format_candidate (const ice_candidate_t *candidate, char *line, size_t line_size) |
| Format ICE candidate to attribute string. | |
| asciichat_error_t | ice_gather_candidates (const ice_config_t *config) |
| Start ICE candidate gathering. | |
| asciichat_error_t | ice_add_remote_candidate (const ice_candidate_t *candidate, const char *mid) |
| Add remote candidate to peer connection. | |
| bool | ice_is_connected (void) |
| Check ICE connection state. | |
| asciichat_error_t | ice_get_selected_pair (ice_candidate_t *local_candidate, ice_candidate_t *remote_candidate) |
| Get selected candidate pair. | |
ICE candidate gathering and exchange.
Implements ICE candidate collection from STUN/TURN servers and relay via ACDS signaling.
Definition in file ice.c.
| asciichat_error_t ice_add_remote_candidate | ( | const ice_candidate_t * | candidate, |
| const char * | mid | ||
| ) |
Add remote candidate to peer connection.
Called when receiving candidate from peer. The WebRTC agent will test connectivity with this candidate.
| candidate | Remote candidate from peer |
| mid | Media stream ID |
Definition at line 320 of file ice.c.
References ASCIICHAT_OK, ERROR_INVALID_PARAM, ice_candidate_t::foundation, ice_candidate_type_name(), ice_candidate_t::ip_address, log_debug, ice_candidate_t::port, SET_ERRNO, and ice_candidate_t::type.
| uint32_t ice_calculate_priority | ( | ice_candidate_type_t | type, |
| uint16_t | local_preference, | ||
| uint8_t | component_id | ||
| ) |
Calculate candidate priority.
Implements RFC 5245 priority formula: priority = (2^24 * typePreference) + (2^8 * localPreference) + (256 - componentID)
| type | Candidate type (determines typePreference) |
| local_preference | Local preference (0-65535, higher = preferred) |
| component_id | Component ID (1 or 2) |
Definition at line 51 of file ice.c.
References ICE_CANDIDATE_HOST, ICE_CANDIDATE_PRFLX, ICE_CANDIDATE_RELAY, and ICE_CANDIDATE_SRFLX.
| const char * ice_candidate_type_name | ( | ice_candidate_type_t | type | ) |
Get human-readable candidate type name.
| type | Candidate type |
Definition at line 21 of file ice.c.
References ICE_CANDIDATE_HOST, ICE_CANDIDATE_PRFLX, ICE_CANDIDATE_RELAY, and ICE_CANDIDATE_SRFLX.
Referenced by ice_add_remote_candidate(), and ice_format_candidate().
| asciichat_error_t ice_format_candidate | ( | const ice_candidate_t * | candidate, |
| char * | line, | ||
| size_t | line_size | ||
| ) |
Format ICE candidate to attribute string.
Converts ice_candidate_t structure to SDP attribute line.
| candidate | Candidate to format |
| line | Output buffer for SDP line (without "a=candidate:" prefix) |
| line_size | Size of output buffer |
Definition at line 220 of file ice.c.
References ASCIICHAT_OK, ice_candidate_t::component_id, ERROR_BUFFER_FULL, ERROR_INVALID_PARAM, ice_candidate_t::extensions, ice_candidate_t::foundation, ICE_CANDIDATE_PRFLX, ICE_CANDIDATE_RELAY, ICE_CANDIDATE_SRFLX, ice_candidate_type_name(), ice_protocol_name(), ICE_PROTOCOL_TCP, ICE_TCP_TYPE_ACTIVE, ICE_TCP_TYPE_SO, ice_candidate_t::ip_address, ice_candidate_t::port, ice_candidate_t::priority, ice_candidate_t::protocol, ice_candidate_t::raddr, ice_candidate_t::rport, SET_ERRNO, ice_candidate_t::tcp_type, and ice_candidate_t::type.
| asciichat_error_t ice_gather_candidates | ( | const ice_config_t * | config | ) |
Start ICE candidate gathering.
Initiates gathering of candidates from all sources:
Candidates are reported via callback as they're discovered.
| config | ICE gathering configuration |
Definition at line 286 of file ice.c.
References ASCIICHAT_OK, ERROR_INVALID_PARAM, log_debug, ice_config_t::pwd, ice_config_t::send_callback, SET_ERRNO, and ice_config_t::ufrag.
| asciichat_error_t ice_get_selected_pair | ( | ice_candidate_t * | local_candidate, |
| ice_candidate_t * | remote_candidate | ||
| ) |
Get selected candidate pair.
Returns the local and remote candidates that were selected for data flow.
| local_candidate | Selected local candidate (output, may be NULL) |
| remote_candidate | Selected remote candidate (output, may be NULL) |
Definition at line 362 of file ice.c.
References ERROR_INVALID_STATE, and SET_ERRNO.
| bool ice_is_connected | ( | void | ) |
Check ICE connection state.
Definition at line 352 of file ice.c.
| asciichat_error_t ice_parse_candidate | ( | const char * | line, |
| ice_candidate_t * | candidate | ||
| ) |
Parse ICE candidate from attribute string.
Converts SDP candidate attribute line to ice_candidate_t structure.
Format: a=candidate:foundation component protocol priority ip port typ type [raddr rport] [extensions]
| line | SDP candidate line (without "a=candidate:" prefix) |
| candidate | Parsed candidate (output) |
Definition at line 89 of file ice.c.
References ASCIICHAT_OK, ice_candidate_t::component_id, ERROR_INVALID_PARAM, ice_candidate_t::foundation, ICE_CANDIDATE_HOST, ICE_CANDIDATE_PRFLX, ICE_CANDIDATE_RELAY, ICE_CANDIDATE_SRFLX, ICE_PROTOCOL_TCP, ICE_PROTOCOL_UDP, ICE_TCP_TYPE_ACTIVE, ICE_TCP_TYPE_PASSIVE, ICE_TCP_TYPE_SO, ice_candidate_t::ip_address, ice_candidate_t::port, ice_candidate_t::priority, ice_candidate_t::protocol, ice_candidate_t::raddr, ice_candidate_t::rport, SAFE_STRNCPY, SET_ERRNO, ice_candidate_t::tcp_type, and ice_candidate_t::type.
| const char * ice_protocol_name | ( | ice_protocol_t | protocol | ) |
Get human-readable protocol name.
| protocol | Protocol type |
Definition at line 36 of file ice.c.
References ICE_PROTOCOL_TCP, and ICE_PROTOCOL_UDP.
Referenced by ice_format_candidate().