ascii-chat
Binary v0.16.50-198-g78f51665f
Library lib/v0.3.2-2240-g78f51665f
Video chat in your terminal
Loading...
Searching...
No Matches
webrtc.c File Reference

Go to the source code of this file.

Data Structures

struct  webrtc_peer_connection
 WebRTC data channel for sending/receiving messages. More...
struct  webrtc_data_channel
 When code needs to work with webrtc peer connection, it keeps mapping, port_reservation, mapping_thread, mapping_stop here instead of scattering it across globals. Initialization establishes the handles and sizes; teardown must release any allocation, lock, thread, or callback context recorded in those fields. More...

Macros

#define NETWORK_WEBRTC_LOCAL_CANDIDATE_BUFFER_SIZE   512
#define NETWORK_WEBRTC_REMOTE_CANDIDATE_BUFFER_SIZE   512
#define NETWORK_WEBRTC_PC_NAME_BUFFER_SIZE   64
#define NETWORK_WEBRTC_LABEL_BUFFER_SIZE   256
#define WEBRTC_AUTH_INPUT_BUFFER_SIZE   128
#define WEBRTC_PERCENT_ESCAPE_EXPANSION   3
#define WEBRTC_ESCAPED_AUTH_BUFFER_SIZE   (WEBRTC_AUTH_INPUT_BUFFER_SIZE * WEBRTC_PERCENT_ESCAPE_EXPANSION)
#define WEBRTC_TURN_URL_BUFFER_SIZE   1024

Functions

asciichat_error_t webrtc_init (void)
 Initialize WebRTC library (libdatachannel).
void webrtc_destroy (void)
 Cleanup WebRTC library resources.
asciichat_error_t webrtc_create_peer_connection (const webrtc_config_t *config, webrtc_peer_connection_t **pc_out)
 Create a new WebRTC peer connection.
void webrtc_close_peer_connection (webrtc_peer_connection_t *pc)
 Close and destroy a peer connection.
webrtc_state_t webrtc_get_state (webrtc_peer_connection_t *pc)
 Get current connection state.
webrtc_gathering_state_t webrtc_get_gathering_state (webrtc_peer_connection_t *pc)
 Get current ICE gathering state.
bool webrtc_is_gathering_timed_out (webrtc_peer_connection_t *pc, uint32_t timeout_ms)
 Check if ICE gathering has timed out.
void * webrtc_get_user_data (webrtc_peer_connection_t *pc)
 Get user data pointer from connection.
asciichat_error_t webrtc_create_offer (webrtc_peer_connection_t *pc)
 Create and set local SDP offer (for connection initiator).
asciichat_error_t webrtc_set_remote_description (webrtc_peer_connection_t *pc, const char *sdp, const char *type)
 Set remote SDP offer/answer.
asciichat_error_t webrtc_add_remote_candidate (webrtc_peer_connection_t *pc, const char *candidate, const char *mid)
 Add remote ICE candidate.
asciichat_error_t webrtc_create_datachannel (webrtc_peer_connection_t *pc, const char *label, webrtc_data_channel_t **dc_out)
 Create a DataChannel (for connection initiator).
asciichat_error_t webrtc_datachannel_get_buffered_amount (webrtc_data_channel_t *dc, size_t *amount)
asciichat_error_t webrtc_datachannel_get_max_message_size (webrtc_data_channel_t *dc, size_t *size)
asciichat_error_t webrtc_datachannel_send (webrtc_data_channel_t *dc, const uint8_t *data, size_t size)
 Send data over DataChannel.
bool webrtc_datachannel_is_open (webrtc_data_channel_t *dc)
 Check if DataChannel is open and ready.
void webrtc_datachannel_set_open_state (webrtc_data_channel_t *dc, bool is_open)
 Set DataChannel open state (internal use).
const char * webrtc_datachannel_get_label (webrtc_data_channel_t *dc)
 Get DataChannel label.
void webrtc_close_datachannel (webrtc_data_channel_t *dc)
 Close a DataChannel.
asciichat_error_t webrtc_datachannel_set_callbacks (webrtc_data_channel_t *dc, const webrtc_datachannel_callbacks_t *callbacks)
 Set DataChannel callbacks.
void webrtc_datachannel_destroy (webrtc_data_channel_t *dc)
 Destroy a DataChannel and free resources.
void webrtc_peer_connection_close (webrtc_peer_connection_t *pc)
 Close a peer connection.
void webrtc_peer_connection_destroy (webrtc_peer_connection_t *pc)
 Destroy a peer connection and free resources.
int webrtc_get_rtc_id (webrtc_peer_connection_t *pc)
 Get the internal libdatachannel peer connection ID.

Macro Definition Documentation

◆ NETWORK_WEBRTC_LABEL_BUFFER_SIZE

#define NETWORK_WEBRTC_LABEL_BUFFER_SIZE   256

Definition at line 6 of file lib/network/webrtc/webrtc.c.

Referenced by webrtc_datachannel_get_label().

◆ NETWORK_WEBRTC_LOCAL_CANDIDATE_BUFFER_SIZE

#define NETWORK_WEBRTC_LOCAL_CANDIDATE_BUFFER_SIZE   512

Definition at line 3 of file lib/network/webrtc/webrtc.c.

◆ NETWORK_WEBRTC_PC_NAME_BUFFER_SIZE

#define NETWORK_WEBRTC_PC_NAME_BUFFER_SIZE   64

Definition at line 5 of file lib/network/webrtc/webrtc.c.

Referenced by webrtc_create_peer_connection().

◆ NETWORK_WEBRTC_REMOTE_CANDIDATE_BUFFER_SIZE

#define NETWORK_WEBRTC_REMOTE_CANDIDATE_BUFFER_SIZE   512

Definition at line 4 of file lib/network/webrtc/webrtc.c.

◆ WEBRTC_AUTH_INPUT_BUFFER_SIZE

#define WEBRTC_AUTH_INPUT_BUFFER_SIZE   128

Definition at line 9 of file lib/network/webrtc/webrtc.c.

◆ WEBRTC_ESCAPED_AUTH_BUFFER_SIZE

#define WEBRTC_ESCAPED_AUTH_BUFFER_SIZE   (WEBRTC_AUTH_INPUT_BUFFER_SIZE * WEBRTC_PERCENT_ESCAPE_EXPANSION)

Definition at line 11 of file lib/network/webrtc/webrtc.c.

Referenced by webrtc_create_peer_connection().

◆ WEBRTC_PERCENT_ESCAPE_EXPANSION

#define WEBRTC_PERCENT_ESCAPE_EXPANSION   3

Definition at line 10 of file lib/network/webrtc/webrtc.c.

◆ WEBRTC_TURN_URL_BUFFER_SIZE

#define WEBRTC_TURN_URL_BUFFER_SIZE   1024

Definition at line 14 of file lib/network/webrtc/webrtc.c.

Referenced by webrtc_create_peer_connection().