ascii-chat 0.6.0
Real-time terminal-based video chat with ASCII art conversion
Loading...
Searching...
No Matches
messages.h
Go to the documentation of this file.
1
24#pragma once
25
26#include "network/packet.h"
27#include "network/acip/acds.h"
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 ||
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
acip_session_join_t
acip_session_joined_t
acip_session_lookup_t
acip_webrtc_ice_t
acip_session_created_t
acip_webrtc_sdp_t
acip_session_create_t
acip_session_info_t
unsigned short uint16_t
Definition common.h:57
@ PACKET_TYPE_ACIP_WEBRTC_ICE
WebRTC ICE candidate (bidirectional)
Definition packet.h:390
@ PACKET_TYPE_AUDIO_OPUS_BATCH
Batched Opus-encoded audio frames.
Definition packet.h:359
@ PACKET_TYPE_AUDIO_OPUS
Opus-encoded single audio frame.
Definition packet.h:357
@ PACKET_TYPE_CLIENT_LEAVE
Clean disconnect notification.
Definition packet.h:302
@ PACKET_TYPE_ACIP_SESSION_INFO
Session info response (Discovery Server -> Client)
Definition packet.h:375
@ PACKET_TYPE_IMAGE_FRAME
Complete RGB image with dimensions.
Definition packet.h:288
@ PACKET_TYPE_TEXT_MESSAGE
Text message.
Definition packet.h:350
@ PACKET_TYPE_AUDIO_MESSAGE
Audio message.
Definition packet.h:348
@ PACKET_TYPE_PONG
Keepalive pong response.
Definition packet.h:297
@ PACKET_TYPE_STREAM_START
Client requests to start sending video/audio.
Definition packet.h:304
@ PACKET_TYPE_ACIP_ERROR
Generic error response (Discovery Server -> Client)
Definition packet.h:404
@ PACKET_TYPE_AUDIO
Single audio packet (legacy)
Definition packet.h:291
@ PACKET_TYPE_SERVER_STATE
Server sends current state to clients.
Definition packet.h:310
@ PACKET_TYPE_SIZE_MESSAGE
Terminal size message.
Definition packet.h:346
@ PACKET_TYPE_REMOTE_LOG
Bidirectional remote logging packet.
Definition packet.h:354
@ PACKET_TYPE_PROTOCOL_VERSION
Protocol version and capabilities negotiation.
Definition packet.h:283
@ PACKET_TYPE_CLEAR_CONSOLE
Server tells client to clear console.
Definition packet.h:308
@ PACKET_TYPE_ACIP_SESSION_CREATE
Create new session (Client -> Discovery Server)
Definition packet.h:369
@ PACKET_TYPE_ASCII_FRAME
Complete ASCII frame with all metadata.
Definition packet.h:286
@ PACKET_TYPE_ACIP_SESSION_LOOKUP
Lookup session by string (Client -> Discovery Server)
Definition packet.h:373
@ PACKET_TYPE_ACIP_WEBRTC_SDP
WebRTC SDP offer/answer (bidirectional)
Definition packet.h:388
@ PACKET_TYPE_ACIP_SESSION_JOIN
Join existing session (Client -> Discovery Server)
Definition packet.h:377
@ PACKET_TYPE_ACIP_SESSION_CREATED
Session created response (Discovery Server -> Client)
Definition packet.h:371
@ PACKET_TYPE_CLIENT_JOIN
Client announces capability to send media.
Definition packet.h:300
@ PACKET_TYPE_CLIENT_CAPABILITIES
Client reports terminal capabilities.
Definition packet.h:293
@ PACKET_TYPE_ERROR_MESSAGE
Error packet with asciichat_error_t code and human-readable message.
Definition packet.h:352
@ PACKET_TYPE_PING
Keepalive ping packet.
Definition packet.h:295
@ PACKET_TYPE_AUDIO_BATCH
Batched audio packets for efficiency.
Definition packet.h:343
@ PACKET_TYPE_ACIP_SESSION_JOINED
Session joined response (Discovery Server -> Client)
Definition packet.h:379
@ PACKET_TYPE_STREAM_STOP
Client stops sending media.
Definition packet.h:306
const char * acip_packet_type_name(uint16_t type)
Get human-readable name for packet type.
ASCII-Chat Discovery Service (ACDS) Protocol Message Formats.
Packet protocol implementation with encryption and compression support.
ASCII frame packet structure (Packet Type 2)
Definition packet.h:740
Audio batch packet structure (Packet Type 28)
Definition packet.h:796
Error packet structure carrying error code and textual description.
Definition packet.h:619
Image frame packet structure (Packet Type 3)
Definition packet.h:768
Protocol version negotiation packet structure (Packet Type 1)
Definition packet.h:710
Remote log packet structure carrying log level and message text.
Definition packet.h:633
Server state packet structure.
Definition packet.h:598