ascii-chat
Binary v0.16.114-28-gf5913657f
Library lib/v0.3.2-3302-gf5913657f
Video chat in your terminal
Loading...
Searching...
No Matches
messages.h
Go to the documentation of this file.
1
23
24#pragma once
25
28#include <stdint.h>
29#include <stdbool.h>
30
31#ifdef __cplusplus
32extern "C" {
33#endif
34
35// =============================================================================
36// ACIP Packet Classification Helpers
37// =============================================================================
38
45static inline bool acip_is_media_packet(uint16_t type) {
47}
48
55static inline bool acip_is_control_packet(uint16_t type) {
58}
59
66static inline bool acip_is_crypto_packet(uint16_t type) {
67 return packet_is_handshake_type((packet_type_t)type);
68}
69
76static inline bool acip_is_message_packet(uint16_t type) {
78}
79
80// =============================================================================
81// Packet Size Helpers
82// =============================================================================
83
93static inline size_t acip_get_min_packet_size(uint16_t type) {
94 switch (type) {
96 return sizeof(protocol_version_packet_t);
98 return sizeof(ascii_frame_packet_t);
100 return sizeof(image_frame_packet_t);
102 return sizeof(audio_batch_packet_t);
104 return sizeof(server_state_packet_t);
106 return sizeof(error_packet_t);
108 return sizeof(remote_log_packet_t);
109 case PACKET_TYPE_PING:
110 case PACKET_TYPE_PONG:
111 return 0; // No payload
113 return sizeof(acip_session_create_t);
115 return sizeof(acip_session_created_t);
117 return sizeof(acip_session_lookup_t);
119 return sizeof(acip_session_info_t);
121 return sizeof(acip_session_join_t);
123 return sizeof(acip_session_joined_t);
125 return sizeof(acip_webrtc_sdp_t);
127 return sizeof(acip_webrtc_ice_t);
129 return sizeof(acip_error_t);
130 default:
131 return 0; // Variable or unknown size
132 }
133}
134
135// =============================================================================
136// Message Type Strings (for logging/debugging)
137// =============================================================================
138
145const char *acip_packet_type_name(uint16_t type);
146
147#ifdef __cplusplus
148}
149#endif
ascii-chat Discovery Service (ACDS) Protocol Message Formats
unsigned short uint16_t
acip_session_join_t
Definition acds.h:408
acip_session_joined_t
Definition acds.h:479
acip_session_lookup_t
Definition acds.h:309
acip_error_t
Definition acds.h:1013
acip_webrtc_ice_t
Definition acds.h:655
acip_session_created_t
Definition acds.h:274
acip_webrtc_sdp_t
Definition acds.h:609
acip_session_create_t
Definition acds.h:226
acip_session_info_t
Definition acds.h:360
packet_type_t
Network protocol packet type enumeration.
Definition packet.h:315
@ PACKET_TYPE_ACIP_WEBRTC_ICE
WebRTC ICE candidate (bidirectional).
Definition packet.h:466
@ PACKET_TYPE_AUDIO_OPUS_BATCH
Batched Opus-encoded audio frames.
Definition packet.h:412
@ PACKET_TYPE_CLIENT_LEAVE
Clean disconnect notification.
Definition packet.h:427
@ PACKET_TYPE_ACIP_SESSION_INFO
Session info response (Discovery Server -> Client).
Definition packet.h:451
@ PACKET_TYPE_IMAGE_FRAME
Complete RGB image with dimensions.
Definition packet.h:399
@ PACKET_TYPE_TEXT_MESSAGE
Text message.
Definition packet.h:386
@ PACKET_TYPE_AUDIO_MESSAGE
Audio message.
Definition packet.h:384
@ PACKET_TYPE_PONG
Keepalive pong response.
Definition packet.h:423
@ PACKET_TYPE_STREAM_START
Client requests to start sending video/audio.
Definition packet.h:429
@ PACKET_TYPE_ACIP_ERROR
Generic error response (Discovery Server -> Client).
Definition packet.h:547
@ PACKET_TYPE_SERVER_STATE
Server sends current state to clients.
Definition packet.h:435
@ PACKET_TYPE_SIZE_MESSAGE
Terminal size message.
Definition packet.h:382
@ PACKET_TYPE_REMOTE_LOG
Bidirectional remote logging packet.
Definition packet.h:390
@ PACKET_TYPE_PROTOCOL_VERSION
Protocol version and capabilities negotiation.
Definition packet.h:317
@ PACKET_TYPE_CLEAR_CONSOLE
Server tells client to clear console.
Definition packet.h:433
@ PACKET_TYPE_ACIP_SESSION_CREATE
Create new session (Client -> Discovery Server).
Definition packet.h:445
@ PACKET_TYPE_ASCII_FRAME
Complete ASCII frame with all metadata.
Definition packet.h:397
@ PACKET_TYPE_ACIP_SESSION_LOOKUP
Lookup session by string (Client -> Discovery Server).
Definition packet.h:449
@ PACKET_TYPE_ACIP_WEBRTC_SDP
WebRTC SDP offer/answer (bidirectional).
Definition packet.h:464
@ PACKET_TYPE_ACIP_SESSION_JOIN
Join existing session (Client -> Discovery Server).
Definition packet.h:453
@ PACKET_TYPE_ACIP_SESSION_CREATED
Session created response (Discovery Server -> Client).
Definition packet.h:447
@ PACKET_TYPE_CLIENT_JOIN
Client announces capability to send media.
Definition packet.h:425
@ PACKET_TYPE_CLIENT_CAPABILITIES
Client reports terminal capabilities.
Definition packet.h:419
@ PACKET_TYPE_ERROR_MESSAGE
Error packet with asciichat_error_t code and human-readable message.
Definition packet.h:388
@ PACKET_TYPE_PING
Keepalive ping packet.
Definition packet.h:421
@ PACKET_TYPE_AUDIO_BATCH
Batched audio packets for efficiency.
Definition packet.h:410
@ PACKET_TYPE_ACIP_SESSION_JOINED
Session joined response (Discovery Server -> Client).
Definition packet.h:455
@ PACKET_TYPE_STREAM_STOP
Client stops sending media.
Definition packet.h:431
const char * acip_packet_type_name(uint16_t type)
Get human-readable name for packet type.
Definition handlers.c:579
The wire metadata for one rendered ASCII frame. width and height describe the terminal grid,...
Definition packet.h:920
The metadata prefix for a batch of encoded audio samples. batch_count, total_samples,...
Definition packet.h:983
Error packet structure carrying error code and textual description.
Definition packet.h:778
Describes one compressed image sent through ACIP. width, height, and pixel_format tell the decoder ho...
Definition packet.h:952
Protocol version negotiation packet structure (Packet Type 1).
Definition packet.h:871
Remote log packet structure carrying log level and message text.
Definition packet.h:792
Server state packet structure.
Definition packet.h:757