ascii-chat 0.11.33
Video chat in your terminal
Loading...
Searching...
No Matches
host.h
Go to the documentation of this file.
1
50#pragma once
51
52#include <stdbool.h>
53#include <stddef.h>
54#include <stdint.h>
58
59/* ============================================================================
60 * Session Host Types
61 * ============================================================================ */
62
72
80typedef struct {
83
85 char ip_address[64];
86
88 int port;
89
92
95
99
104typedef struct {
111 void (*on_client_join)(session_host_t *h, uint32_t client_id, void *user_data);
112
119 void (*on_client_leave)(session_host_t *h, uint32_t client_id, void *user_data);
120
128 void (*on_frame_received)(session_host_t *h, uint32_t client_id, const image_t *frame, void *user_data);
129
138 void (*on_audio_received)(session_host_t *h, uint32_t client_id, const float *samples, size_t count, void *user_data);
139
147 void (*on_error)(session_host_t *h, asciichat_error_t error, const char *message, void *user_data);
149
154typedef struct {
156 int port;
157
159 const char *ipv4_address;
160
162 const char *ipv6_address;
163
166
169
171 const char *key_path;
172
174 const char *password;
175
178
181
185
186/* ============================================================================
187 * Session Host Lifecycle Functions
188 * @{
189 */
190
205
216
219/* ============================================================================
220 * Session Host Server Control Functions
221 * @{
222 */
223
235
245
254
257/* ============================================================================
258 * Session Host Client Management Functions
259 * @{
260 */
261
277uint32_t session_host_add_client(session_host_t *host, socket_t socket, const char *ip, int port);
278
294
311
329 size_t count);
330
344
357
366
376int session_host_get_client_ids(session_host_t *host, uint32_t *ids, int max_ids);
377
380/* ============================================================================
381 * Session Host Broadcast Functions
382 * @{
383 */
384
396
407
410/* ============================================================================
411 * Session Host Render Thread Functions
412 * @{
413 */
414
430
446
456
459/* ============================================================================
460 * Session Host Transport Functions (WebRTC Integration)
461 * @{
462 */
463
475
495 acip_transport_t *transport);
496
510
524
⚠️‼️ Comprehensive thread-local error context system for ascii-chat
unsigned int uint32_t
Definition common.h:58
unsigned long long uint64_t
Definition common.h:59
asciichat_error_t
Error and exit codes - unified status values (0-255)
Definition error_codes.h:49
void session_host_stop_render(session_host_t *host)
Stop media rendering thread.
Definition host.c:1630
asciichat_error_t session_host_inject_audio(session_host_t *host, uint32_t participant_id, const float *samples, size_t count)
Inject audio samples from memory participant.
Definition host.c:1348
bool session_host_client_has_transport(session_host_t *host, uint32_t client_id)
Check if a specific client has an active alternative transport.
Definition host.c:1738
bool session_host_is_running(session_host_t *host)
Check if host is running.
Definition host.c:1146
asciichat_error_t session_host_inject_frame(session_host_t *host, uint32_t participant_id, const image_t *frame)
Inject a video frame from memory participant.
Definition host.c:1303
uint32_t session_host_add_memory_participant(session_host_t *host)
Add a memory participant (host's own media)
Definition host.c:1227
asciichat_error_t session_host_set_display(session_host_t *host, struct session_display_ctx *display)
Set display context for local frame rendering.
Definition host.c:1558
uint32_t session_host_add_client(session_host_t *host, socket_t socket, const char *ip, int port)
Add a client from an accepted socket.
Definition host.c:1157
void session_host_stop(session_host_t *host)
Stop accepting connections and disconnect all clients.
Definition host.c:1086
acip_transport_t * session_host_get_client_transport(session_host_t *host, uint32_t client_id)
Get the current transport for a specific client in the host.
Definition host.c:1718
asciichat_error_t session_host_send_frame(session_host_t *host, uint32_t client_id, const char *frame)
Send ASCII frame to a specific client.
Definition host.c:1524
asciichat_error_t session_host_set_client_transport(session_host_t *host, uint32_t client_id, acip_transport_t *transport)
Set an alternative transport for a specific client in the host.
Definition host.c:1666
int session_host_get_client_count(session_host_t *host)
Get number of connected clients.
Definition host.c:1460
asciichat_error_t session_host_remove_client(session_host_t *host, uint32_t client_id)
Remove a client by ID.
Definition host.c:1391
asciichat_error_t session_host_find_client(session_host_t *host, uint32_t client_id, session_host_client_info_t *info)
Find a client by ID.
Definition host.c:1435
asciichat_error_t session_host_start(session_host_t *host)
Start accepting client connections.
Definition host.c:1026
int session_host_get_client_ids(session_host_t *host, uint32_t *ids, int max_ids)
Get list of all connected client IDs.
Definition host.c:1467
asciichat_error_t session_host_broadcast_frame(session_host_t *host, const char *frame)
Broadcast ASCII frame to all clients.
Definition host.c:1489
void session_host_destroy(session_host_t *host)
Destroy session host and free resources.
Definition host.c:249
session_host_t * session_host_create(const session_host_config_t *config)
Create a new session host.
Definition host.c:193
asciichat_error_t session_host_start_render(session_host_t *host)
Start media rendering thread (video mixing and audio distribution)
Definition host.c:1571
int socket_t
Cross-platform socket interface for ascii-chat.
int frame
Definition splash.c:99
uint8_t participant_id[16]
ClangTool/LibTooling compatibility shim for stdbool.h.
Transport instance structure.
Definition transport.h:214
Image structure.
Internal session display context structure.
Callback function prototypes for session host events.
Definition host.h:104
Client information structure.
Definition host.h:80
uint64_t connected_at
Connection timestamp (Unix time)
Definition host.h:97
int port
Client port.
Definition host.h:88
bool audio_active
Client is currently streaming audio.
Definition host.h:94
uint32_t client_id
Unique client identifier.
Definition host.h:82
bool video_active
Client is currently streaming video.
Definition host.h:91
Configuration for session host.
Definition host.h:154
void * user_data
User-provided context pointer passed to callbacks.
Definition host.h:180
struct session_display_ctx * display_context
Display context for local frame rendering (optional, can be NULL)
Definition host.h:183
const char * ipv6_address
IPv6 address to bind to (NULL for any)
Definition host.h:162
session_host_callbacks_t callbacks
Event callbacks.
Definition host.h:177
bool encryption_enabled
Enable encryption (default: true)
Definition host.h:168
const char * key_path
Path to server identity key.
Definition host.h:171
int port
Port to listen on (default: 27224)
Definition host.h:156
const char * password
Password for client authentication (optional)
Definition host.h:174
const char * ipv4_address
IPv4 address to bind to (NULL for any)
Definition host.h:159
int max_clients
Maximum number of clients.
Definition host.h:165
Internal session host structure.
Definition host.c:106