ascii-chat
Binary v0.16.50-198-g78f51665f
Library lib/v0.3.2-2240-g78f51665f
Video chat in your terminal
Loading...
Searching...
No Matches
src/client/server.h
Go to the documentation of this file.
1
12
13#pragma once
14
15#include "connection.h"
17
18#include <libplatform/socket.h>
20#include <ascii-chat/log/log.h>
21#include <stdint.h>
22#include <stdbool.h>
23
24/* ============================================================================
25 * Connection Error Codes
26 * ============================================================================ */
27
41
42/* ============================================================================
43 * Connection Management Functions
44 * ============================================================================ */
45
53
55
63
73void server_connection_set_transport(client_connection_t *connection, struct acip_transport *transport);
74
82
89const char *server_connection_get_ip(client_connection_t *connection);
90
97void server_connection_set_ip(client_connection_t *connection, const char *ip);
98
105void server_connection_set_port(client_connection_t *connection, int port);
106
114
121
131
139
153asciichat_error_t threaded_send_packet(client_connection_t *connection, packet_type_t type, const void *data, size_t len);
154
165asciichat_error_t threaded_send_audio_batch_packet(client_connection_t *connection, const float *samples, int num_samples, int batch_count);
166
181asciichat_error_t threaded_send_audio_opus(client_connection_t *connection, const uint8_t *opus_data, size_t opus_size, int sample_rate, int frame_duration);
182
197asciichat_error_t threaded_send_audio_opus_batch(client_connection_t *connection, const uint8_t *opus_data, size_t opus_size, const uint16_t *frame_sizes, int frame_count);
198
213asciichat_error_t threaded_send_image_frame(client_connection_t *connection, const void *pixel_data, uint32_t width, uint32_t height, uint32_t pixel_format);
214
231asciichat_error_t threaded_send_image_frame_encoded(client_connection_t *connection, const void *pixel_data, uint32_t width, uint32_t height, video_codec_t codec, bool *encoding_failed);
232
241
250
260
271
281asciichat_error_t threaded_send_client_join_packet(client_connection_t *connection, const char *display_name, uint32_t capabilities);
282
283/* ============================================================================
284 * Thread-Safe Packet Sending Functions
285 * ============================================================================ */
286
296int server_send_packet(packet_type_t type, const void *data, size_t len);
297
306int server_send_audio(const float *samples, int num_samples);
307
317int server_send_audio_batch(const float *samples, int num_samples, int batch_count);
318
327int server_send_terminal_capabilities(unsigned short width, unsigned short height);
328
336
344
353
Video and audio codec definitions and capability bitmasks.
video_codec_t
Definition codecs.h:28
unsigned int height
Definition fft.c:24
unsigned int width
Definition fft.c:24
unsigned short uint16_t
unsigned int uint32_t
unsigned char uint8_t
asciichat_error_t
Error and exit codes - unified status values (0-255).
Definition error_codes.h:48
packet_type_t
Network protocol packet type enumeration.
Definition packet.h:315
📝 Logging API with multiple log levels and terminal output control
struct client_connection client_connection_t
int server_send_packet(packet_type_t type, const void *data, size_t len)
Send general packet to server.
asciichat_error_t threaded_send_image_frame_encoded(client_connection_t *connection, const void *pixel_data, uint32_t width, uint32_t height, video_codec_t codec, bool *encoding_failed)
Send HEVC/H.264-encoded video frame to server (thread-safe).
void server_connection_shutdown(client_connection_t *connection)
Interrupt connection I/O from normal thread context.
asciichat_error_t threaded_send_packet(client_connection_t *connection, packet_type_t type, const void *data, size_t len)
Thread-safe packet transmission.
asciichat_error_t threaded_send_terminal_size_with_auto_detect(client_connection_t *connection, unsigned short width, unsigned short height)
Thread-safe terminal size packet transmission with auto-detection.
int server_send_terminal_capabilities(unsigned short width, unsigned short height)
Send terminal capabilities to server.
asciichat_error_t threaded_send_audio_batch_packet(client_connection_t *connection, const float *samples, int num_samples, int batch_count)
Thread-safe batched audio packet transmission.
asciichat_error_t threaded_send_stream_start_packet(client_connection_t *connection, uint32_t stream_type)
Thread-safe stream start packet transmission.
void server_connection_set_remote_error(client_connection_t *connection, asciichat_error_t code)
Atomic flag indicating if connection is currently active.
uint32_t server_connection_get_client_id(client_connection_t *connection)
Get client ID assigned by server.
int server_connection_get_port(client_connection_t *connection)
Get the server port.
asciichat_error_t threaded_send_client_join_packet(client_connection_t *connection, const char *display_name, uint32_t capabilities)
Thread-safe client join packet transmission.
bool server_connection_is_active(client_connection_t *connection)
Establish connection to ascii-chat server.
const char * server_connection_get_ip(client_connection_t *connection)
Get resolved server IP address.
int server_send_stream_start(uint32_t stream_type)
Send stream start notification.
void server_connection_lost(client_connection_t *connection)
Signal that connection has been lost.
int server_send_audio(const float *samples, int num_samples)
Send audio data to server.
asciichat_error_t threaded_send_audio_opus_batch(client_connection_t *connection, const uint8_t *opus_data, size_t opus_size, const uint16_t *frame_sizes, int frame_count)
Thread-safe Opus audio batch packet transmission.
int server_send_audio_batch(const float *samples, int num_samples, int batch_count)
Send batched audio data to server.
asciichat_error_t threaded_send_pong_packet(client_connection_t *connection)
Thread-safe pong packet transmission.
struct acip_transport * server_connection_get_transport(client_connection_t *connection)
Get ACIP transport instance.
asciichat_error_t threaded_send_audio_opus(client_connection_t *connection, const uint8_t *opus_data, size_t opus_size, int sample_rate, int frame_duration)
Thread-safe Opus audio frame transmission.
asciichat_error_t server_connection_get_remote_error(client_connection_t *connection)
int server_send_stream_stop(uint32_t stream_type)
Send stream stop notification.
bool server_connection_is_lost(client_connection_t *connection)
Check if connection loss was detected.
int server_send_ping()
Send ping keepalive packet.
void server_connection_pong_received(client_connection_t *connection)
Signal that connection has been lost.
connection_error_t
Connection establishment error codes.
@ CONNECTION_ERROR_GENERIC
Generic error (retry allowed).
@ CONNECTION_ERROR_HOST_KEY_FAILED
Host key verification failed (no retry).
@ CONNECTION_SUCCESS
Connection established successfully.
@ CONNECTION_ERROR_AUTH_FAILED
Authentication failure (no retry).
@ CONNECTION_WARNING_NO_CLIENT_AUTH
Server not using client verification (warning).
int server_connection_init(client_connection_t *connection)
Initialize server connection management subsystem.
void server_connection_set_port(client_connection_t *connection, int port)
Set the server port.
void server_connection_set_ip(client_connection_t *connection, const char *ip)
Set the server IP address.
void server_connection_set_transport(client_connection_t *connection, struct acip_transport *transport)
Set ACIP transport instance from connection fallback.
int server_send_pong()
Send pong response packet.
asciichat_error_t threaded_send_image_frame(client_connection_t *connection, const void *pixel_data, uint32_t width, uint32_t height, uint32_t pixel_format)
Thread-safe image frame transmission.
asciichat_error_t threaded_send_ping_packet(client_connection_t *connection)
Thread-safe ping packet transmission.