|
ascii-chat 0.8.38
Real-time terminal-based video chat with ASCII art conversion
|
🎬 Multi-client video mixer: frame generation, ASCII conversion, and per-client personalized rendering More...
Go to the source code of this file.
Data Structures | |
| struct | image_source_t |
| Image source structure for multi-client video mixing. More... | |
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. | |
| 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. | |
| bool | any_clients_sending_video (void) |
| Check if any connected clients are currently sending video. | |
🎬 Multi-client video mixer: frame generation, ASCII conversion, and per-client personalized rendering
The mixing system operates in several stages:
Unlike traditional video mixing that generates one output, this system creates personalized frames for each client:
TERMINAL CAPABILITY AWARENESS:
PERFORMANCE OPTIMIZATIONS:
This module operates in a high-concurrency environment:
THREAD SAFETY MECHANISMS:
PERFORMANCE CHARACTERISTICS:
DOUBLE-BUFFER STRATEGY: Each client uses a double-buffer system for smooth frame delivery:
BUFFER OVERFLOW HANDLING: When clients send frames faster than processing:
The original server.c contained all video mixing logic inline, making it:
This separation provides:
Definition in file stream.c.
| 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().