ascii-chat 0.11.33
Video chat in your terminal
Loading...
Searching...
No Matches
client_info Struct Reference

Per-client state structure for server-side client management. More...

#include <include/ascii-chat/network/client.h>

Data Fields

participant_type_t participant_type
 
socket_t socket
 
bool is_tcp_client
 
acip_transport_t * transport
 
asciichat_thread_t receive_thread
 
asciichat_thread_t send_thread
 
thread_id_t send_thread_id
 
thread_id_t receive_thread_id
 
void * server_ctx
 
char client_id [MAX_CLIENT_ID_LEN]
 
uint32_t session_client_id
 
char display_name [MAX_DISPLAY_NAME_LEN]
 
char client_ip [INET_ADDRSTRLEN]
 
int port
 
bool can_send_video
 
bool can_send_audio
 
bool wants_stretch
 
atomic_t is_sending_video
 
atomic_t is_sending_audio
 
uint32_t codec_capabilities_video
 
uint32_t codec_capabilities_audio
 
void * opus_decoder
 
void * h265_decoder_ctx
 
void * h265_decode_frame
 
void * h265_rgb_frame
 
void * h265_sws_ctx
 
terminal_capabilities_t terminal_caps
 
bool has_terminal_caps
 
char client_palette_chars [256]
 
size_t client_palette_len
 
char client_luminance_palette [256]
 
palette_type_t client_palette_type
 
bool client_palette_initialized
 
digital_rain_t * digital_rain
 
double digital_rain_last_update_time
 
uint16_t width
 
uint16_t height
 
atomic_t active
 
atomic_t shutting_down
 
atomic_t protocol_disconnect_requested
 
time_t connected_at
 
uint64_t frames_sent
 
uint64_t frames_received
 
uint32_t frames_received_logged
 
uint64_t video_receive_rate_window_ns
 
uint32_t video_receive_rate_window_frames
 
uint32_t last_received_frame_hash
 
video_frame_buffer_t * incoming_video_buffer
 
audio_ring_buffer_t * incoming_audio_buffer
 
video_frame_buffer_t * outgoing_video_buffer
 
packet_queue_t * audio_queue
 
packet_queue_t * received_packet_queue
 
asciichat_thread_t dispatch_thread
 
atomic_t dispatch_thread_running
 
cond_t dispatch_queue_cond
 
atomic_t send_thread_running
 
atomic_t last_rendered_grid_sources
 
atomic_t last_sent_grid_sources
 
atomic_t frames_sent_count
 
void * send_buffer
 
size_t send_buffer_size
 
void * crypto_plaintext_buffer
 
size_t crypto_plaintext_size
 
void * crypto_ciphertext_buffer
 
size_t crypto_ciphertext_size
 
asciichat_thread_t video_render_thread
 
asciichat_thread_t audio_render_thread
 
atomic_t video_render_thread_running
 
atomic_t audio_render_thread_running
 
mutex_t client_state_mutex
 
mutex_t send_mutex
 
crypto_handshake_context_t crypto_handshake_ctx
 
bool crypto_initialized
 
bool transport_encrypted
 TLS or DTLS already encrypts this client's transport.
 
bool encrypt_data
 
packet_type_t pending_packet_type
 
void * pending_packet_payload
 
size_t pending_packet_length
 
UT_hash_handle hh
 

Detailed Description

Per-client state structure for server-side client management.

Represents complete state for a single connected client in the ascii-chat server. This structure stores all client-specific information including network connection, media capabilities, terminal settings, threading state, and synchronization primitives.

CORE FIELDS:

  • Network: Socket, IP address, port, thread handles
  • Media: Video/audio capabilities, stream state, buffers
  • Terminal: Capabilities, palette cache, dimensions
  • Threading: Send/receive/render thread handles and flags
  • Synchronization: Mutexes for thread-safe state access
  • Crypto: Cryptographic handshake context for secure communication

THREADING MODEL:

Each client has dedicated threads:

  • receive_thread: Handles incoming packets (protocol processing)
  • send_thread: Manages outgoing packet delivery (packet queues)
  • video_render_thread: Generates ASCII frames at 60fps
  • audio_render_thread: Mixes audio streams at 172fps

BUFFER MANAGEMENT:

  • incoming_video_buffer: Double-buffered video frames from client
  • incoming_audio_buffer: Ring buffer for client's audio samples
  • outgoing_video_buffer: Double-buffered ASCII frames to send
  • audio_queue: Packet queue for audio packets to send

MEMORY MANAGEMENT:

  • Pre-allocated buffers to avoid malloc/free in hot paths
  • send_buffer: For packet assembly
  • crypto_plaintext_buffer: For encryption plaintext
  • crypto_ciphertext_buffer: For encryption ciphertext
Note
All atomic fields are thread-safe for concurrent access.
Buffer pointers are set once during client creation and never change.
Thread handles are valid only when threads are running.

Definition at line 83 of file include/ascii-chat/network/client.h.

Field Documentation

◆ active

◆ audio_queue

◆ audio_render_thread

asciichat_thread_t client_info::audio_render_thread

◆ audio_render_thread_running

◆ can_send_audio

bool client_info::can_send_audio

Definition at line 101 of file include/ascii-chat/network/client.h.

Referenced by handle_client_join_packet().

◆ can_send_video

bool client_info::can_send_video

Definition at line 100 of file include/ascii-chat/network/client.h.

Referenced by handle_client_join_packet().

◆ client_id

◆ client_ip

char client_info::client_ip[INET_ADDRSTRLEN]

◆ client_luminance_palette

char client_info::client_luminance_palette[256]

◆ client_palette_chars

char client_info::client_palette_chars[256]

◆ client_palette_initialized

bool client_info::client_palette_initialized

◆ client_palette_len

size_t client_info::client_palette_len

◆ client_palette_type

palette_type_t client_info::client_palette_type

◆ client_state_mutex

◆ codec_capabilities_audio

uint32_t client_info::codec_capabilities_audio

◆ codec_capabilities_video

◆ connected_at

time_t client_info::connected_at

Definition at line 141 of file include/ascii-chat/network/client.h.

Referenced by add_client(), and add_webrtc_client().

◆ crypto_ciphertext_buffer

void* client_info::crypto_ciphertext_buffer

Definition at line 180 of file include/ascii-chat/network/client.h.

◆ crypto_ciphertext_size

size_t client_info::crypto_ciphertext_size

Definition at line 181 of file include/ascii-chat/network/client.h.

◆ crypto_handshake_ctx

◆ crypto_initialized

◆ crypto_plaintext_buffer

void* client_info::crypto_plaintext_buffer

Definition at line 178 of file include/ascii-chat/network/client.h.

◆ crypto_plaintext_size

size_t client_info::crypto_plaintext_size

Definition at line 179 of file include/ascii-chat/network/client.h.

◆ digital_rain

digital_rain_t* client_info::digital_rain

Definition at line 131 of file include/ascii-chat/network/client.h.

Referenced by cleanup_client_media_buffers().

◆ digital_rain_last_update_time

double client_info::digital_rain_last_update_time

Definition at line 132 of file include/ascii-chat/network/client.h.

◆ dispatch_queue_cond

cond_t client_info::dispatch_queue_cond

◆ dispatch_thread

asciichat_thread_t client_info::dispatch_thread

Definition at line 161 of file include/ascii-chat/network/client.h.

Referenced by remove_client(), and stop_client_threads().

◆ dispatch_thread_running

atomic_t client_info::dispatch_thread_running

◆ display_name

◆ encrypt_data

bool client_info::encrypt_data

Definition at line 197 of file include/ascii-chat/network/client.h.

Referenced by server_crypto_handshake().

◆ frames_received

uint64_t client_info::frames_received

◆ frames_received_logged

uint32_t client_info::frames_received_logged

Definition at line 144 of file include/ascii-chat/network/client.h.

Referenced by handle_image_frame_packet().

◆ frames_sent

uint64_t client_info::frames_sent

Definition at line 142 of file include/ascii-chat/network/client.h.

Referenced by update_server_stats().

◆ frames_sent_count

atomic_t client_info::frames_sent_count

Definition at line 173 of file include/ascii-chat/network/client.h.

Referenced by client_send_thread_func().

◆ h265_decode_frame

void* client_info::h265_decode_frame

Definition at line 115 of file include/ascii-chat/network/client.h.

Referenced by cleanup_client_media_buffers().

◆ h265_decoder_ctx

void* client_info::h265_decoder_ctx

Definition at line 114 of file include/ascii-chat/network/client.h.

Referenced by cleanup_client_media_buffers().

◆ h265_rgb_frame

void* client_info::h265_rgb_frame

Definition at line 116 of file include/ascii-chat/network/client.h.

Referenced by cleanup_client_media_buffers().

◆ h265_sws_ctx

void* client_info::h265_sws_ctx

Definition at line 117 of file include/ascii-chat/network/client.h.

Referenced by cleanup_client_media_buffers().

◆ has_terminal_caps

bool client_info::has_terminal_caps

◆ height

◆ hh

UT_hash_handle client_info::hh

Definition at line 207 of file include/ascii-chat/network/client.h.

◆ incoming_audio_buffer

◆ incoming_video_buffer

◆ is_sending_audio

◆ is_sending_video

◆ is_tcp_client

◆ last_received_frame_hash

uint32_t client_info::last_received_frame_hash

Definition at line 147 of file include/ascii-chat/network/client.h.

Referenced by handle_image_frame_packet().

◆ last_rendered_grid_sources

atomic_t client_info::last_rendered_grid_sources

◆ last_sent_grid_sources

atomic_t client_info::last_sent_grid_sources

◆ opus_decoder

◆ outgoing_video_buffer

◆ participant_type

participant_type_t client_info::participant_type

Definition at line 84 of file include/ascii-chat/network/client.h.

◆ pending_packet_length

size_t client_info::pending_packet_length

◆ pending_packet_payload

void* client_info::pending_packet_payload

◆ pending_packet_type

packet_type_t client_info::pending_packet_type

◆ port

int client_info::port

Definition at line 97 of file include/ascii-chat/network/client.h.

Referenced by add_client(), and add_webrtc_client().

◆ protocol_disconnect_requested

atomic_t client_info::protocol_disconnect_requested

◆ receive_thread

asciichat_thread_t client_info::receive_thread

Definition at line 88 of file include/ascii-chat/network/client.h.

Referenced by remove_client(), and stop_client_threads().

◆ receive_thread_id

thread_id_t client_info::receive_thread_id

Definition at line 91 of file include/ascii-chat/network/client.h.

Referenced by client_receive_thread(), and remove_client().

◆ received_packet_queue

◆ send_buffer

void* client_info::send_buffer

◆ send_buffer_size

size_t client_info::send_buffer_size

◆ send_mutex

◆ send_thread

asciichat_thread_t client_info::send_thread

Definition at line 89 of file include/ascii-chat/network/client.h.

Referenced by remove_client(), and stop_client_threads().

◆ send_thread_id

thread_id_t client_info::send_thread_id

Definition at line 90 of file include/ascii-chat/network/client.h.

Referenced by client_send_thread_func().

◆ send_thread_running

◆ server_ctx

void* client_info::server_ctx

◆ session_client_id

uint32_t client_info::session_client_id

◆ shutting_down

◆ socket

◆ terminal_caps

◆ transport

◆ transport_encrypted

bool client_info::transport_encrypted

TLS or DTLS already encrypts this client's transport.

Definition at line 196 of file include/ascii-chat/network/client.h.

Referenced by add_client(), add_webrtc_client(), and client_send_thread_func().

◆ video_receive_rate_window_frames

uint32_t client_info::video_receive_rate_window_frames

Definition at line 146 of file include/ascii-chat/network/client.h.

◆ video_receive_rate_window_ns

uint64_t client_info::video_receive_rate_window_ns

Definition at line 145 of file include/ascii-chat/network/client.h.

◆ video_render_thread

asciichat_thread_t client_info::video_render_thread

◆ video_render_thread_running

◆ wants_stretch

bool client_info::wants_stretch

Definition at line 102 of file include/ascii-chat/network/client.h.

Referenced by handle_client_join_packet().

◆ width


The documentation for this struct was generated from the following file: