|
ascii-chat 0.8.38
Real-time terminal-based video chat with ASCII art conversion
|
Multi-client video mixing and ASCII frame generation. More...
Go to the source code of this file.
Functions | |
| char * | create_mixed_ascii_frame_for_client (uint32_t target_client_id, unsigned short width, unsigned short height, bool wants_stretch, size_t *out_size, bool *out_grid_changed, int *out_sources_count) |
| Generate personalized ASCII frame for a specific client. | |
| bool | any_clients_sending_video (void) |
| Check if any connected clients are currently sending video. | |
| int | queue_audio_for_client (client_info_t *client, const void *audio_data, size_t data_size) |
| Queue ASCII frame for delivery to specific client. | |
Variables | |
| atomic_bool | g_server_should_exit |
| Global atomic shutdown flag shared across all threads. | |
Multi-client video mixing and ASCII frame generation.
Definition in file stream.h.
| bool any_clients_sending_video | ( | void | ) |
Check if any connected clients are currently sending video.
This function scans all active clients to determine if at least one is sending video frames. Used by render threads to avoid generating frames when no video sources are available (e.g., during webcam warmup).
LOCK OPTIMIZATION: Uses atomic reads only, no rwlock acquisition This is safe because client_id, active, and is_sending_video are all atomics
Definition at line 1305 of file stream.c.
References client_manager_t::clients, and g_client_manager.
Referenced by client_video_render_thread().
| char * create_mixed_ascii_frame_for_client | ( | uint32_t | target_client_id, |
| unsigned short | width, | ||
| unsigned short | height, | ||
| bool | wants_stretch, | ||
| size_t * | out_size, | ||
| bool * | out_grid_changed, | ||
| int * | out_sources_count | ||
| ) |
Generate personalized ASCII frame for a specific client.
This is the core video mixing function that creates customized ASCII art frames for individual clients. It collects video from all active clients, creates an appropriate grid layout, and converts to ASCII using the target client's terminal capabilities.
FRAME BUFFER MANAGEMENT:
CONCURRENCY OPTIMIZATIONS:
TERMINAL AWARENESS:
RENDERING MODES SUPPORTED:
| target_client_id | Client who will receive this customized frame |
| width | Terminal width in characters for this client |
| height | Terminal height in characters for this client |
| wants_stretch | Unused parameter (aspect ratio always preserved) |
| out_size | Pointer to store resulting ASCII frame size |
Definition at line 955 of file stream.c.
References format_duration_ns(), image_destroy(), image_destroy_to_pool(), image_new_copy(), and time_get_ns().
Referenced by client_video_render_thread().
| int queue_audio_for_client | ( | client_info_t * | client, |
| const void * | audio_data, | ||
| size_t | data_size | ||
| ) |
Queue ASCII frame for delivery to specific client.
Packages a generated ASCII frame into a protocol packet and queues it for asynchronous delivery to the target client. This function handles all protocol details including headers, checksums, and metadata.
| client | Target client for frame delivery |
| ascii_frame | Generated ASCII art string (null-terminated) |
| frame_size | Size of ASCII frame in bytes |
Queue audio data for delivery to specific client
Queues mixed audio data for delivery to a specific client. This is a simple wrapper around the packet queue system for audio delivery.
| client | Target client for audio delivery |
| audio_data | Mixed audio samples (float format) |
| data_size | Size of audio data in bytes |
Definition at line 1285 of file stream.c.
References packet_queue_enqueue().
|
extern |
Global atomic shutdown flag shared across all threads.
Server shutdown flag.
This flag is the primary coordination mechanism for clean server shutdown. It's atomic to ensure thread-safe access without mutexes, as it's checked frequently in tight loops across all worker threads.
USAGE PATTERN:
Definition at line 143 of file server/main.c.
Referenced by client_audio_render_thread(), client_dispatch_thread(), client_receive_thread(), client_send_thread_func(), client_video_render_thread(), handle_image_frame_packet(), server_main(), stats_logger_thread(), and stop_client_render_threads().