ascii-chat
Binary v0.15.83-53-gb711d8720
Library lib/v0.3.2-701-gb711d8720
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// =============================================================================
32// ACIP Packet Classification Helpers
33// =============================================================================
34
41static inline bool acip_is_media_packet(uint16_t type) {
42 return (type == PACKET_TYPE_ASCII_FRAME || type == PACKET_TYPE_IMAGE_FRAME || type == PACKET_TYPE_AUDIO_BATCH ||
44}
45
52static inline bool acip_is_control_packet(uint16_t type) {
54 type == PACKET_TYPE_STREAM_STOP || type == PACKET_TYPE_PING || type == PACKET_TYPE_PONG ||
57}
58
65static inline bool acip_is_crypto_packet(uint16_t type) {
66 return packet_is_handshake_type(type);
67}
68
75static 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);
ascii-chat Discovery Service (ACDS) Protocol Message Formats
unsigned short uint16_t
Definition common.h:61
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_ACIP_WEBRTC_ICE
WebRTC ICE candidate (bidirectional).
Definition packet.h:452
@ PACKET_TYPE_AUDIO_OPUS_BATCH
Batched Opus-encoded audio frames.
Definition packet.h:398
@ PACKET_TYPE_CLIENT_LEAVE
Clean disconnect notification.
Definition packet.h:413
@ PACKET_TYPE_ACIP_SESSION_INFO
Session info response (Discovery Server -> Client).
Definition packet.h:437
@ PACKET_TYPE_IMAGE_FRAME
Complete RGB image with dimensions.
Definition packet.h:385
@ PACKET_TYPE_TEXT_MESSAGE
Text message.
Definition packet.h:372
@ PACKET_TYPE_AUDIO_MESSAGE
Audio message.
Definition packet.h:370
@ PACKET_TYPE_PONG
Keepalive pong response.
Definition packet.h:409
@ PACKET_TYPE_STREAM_START
Client requests to start sending video/audio.
Definition packet.h:415
@ PACKET_TYPE_ACIP_ERROR
Generic error response (Discovery Server -> Client).
Definition packet.h:533
@ PACKET_TYPE_SERVER_STATE
Server sends current state to clients.
Definition packet.h:421
@ PACKET_TYPE_SIZE_MESSAGE
Terminal size message.
Definition packet.h:368
@ PACKET_TYPE_REMOTE_LOG
Bidirectional remote logging packet.
Definition packet.h:376
@ PACKET_TYPE_PROTOCOL_VERSION
Protocol version and capabilities negotiation.
Definition packet.h:303
@ PACKET_TYPE_CLEAR_CONSOLE
Server tells client to clear console.
Definition packet.h:419
@ PACKET_TYPE_ACIP_SESSION_CREATE
Create new session (Client -> Discovery Server).
Definition packet.h:431
@ PACKET_TYPE_ASCII_FRAME
Complete ASCII frame with all metadata.
Definition packet.h:383
@ PACKET_TYPE_ACIP_SESSION_LOOKUP
Lookup session by string (Client -> Discovery Server).
Definition packet.h:435
@ PACKET_TYPE_ACIP_WEBRTC_SDP
WebRTC SDP offer/answer (bidirectional).
Definition packet.h:450
@ PACKET_TYPE_ACIP_SESSION_JOIN
Join existing session (Client -> Discovery Server).
Definition packet.h:439
@ PACKET_TYPE_ACIP_SESSION_CREATED
Session created response (Discovery Server -> Client).
Definition packet.h:433
@ PACKET_TYPE_CLIENT_JOIN
Client announces capability to send media.
Definition packet.h:411
@ PACKET_TYPE_CLIENT_CAPABILITIES
Client reports terminal capabilities.
Definition packet.h:405
@ PACKET_TYPE_ERROR_MESSAGE
Error packet with asciichat_error_t code and human-readable message.
Definition packet.h:374
@ PACKET_TYPE_PING
Keepalive ping packet.
Definition packet.h:407
@ PACKET_TYPE_AUDIO_BATCH
Batched audio packets for efficiency.
Definition packet.h:396
@ PACKET_TYPE_ACIP_SESSION_JOINED
Session joined response (Discovery Server -> Client).
Definition packet.h:441
@ PACKET_TYPE_STREAM_STOP
Client stops sending media.
Definition packet.h:417
const char * acip_packet_type_name(uint16_t type)
Get human-readable name for packet type.
Definition handlers.c:648
The wire metadata for one rendered ASCII frame. width and height describe the terminal grid,...
Definition packet.h:902
The metadata prefix for a batch of encoded audio samples. batch_count, total_samples,...
Definition packet.h:960
Error packet structure carrying error code and textual description.
Definition packet.h:767
Describes one compressed image sent through ACIP. width, height, and pixel_format tell the decoder ho...
Definition packet.h:931
Protocol version negotiation packet structure (Packet Type 1).
Definition packet.h:860
Remote log packet structure carrying log level and message text.
Definition packet.h:781
Server state packet structure.
Definition packet.h:746