ascii-chat 0.11.33
Video chat in your terminal
Loading...
Searching...
No Matches
include/ascii-chat/options/options.h
Go to the documentation of this file.
1
203#pragma once
204
205#include <stdbool.h>
206#include <stdio.h>
207#include "../platform/terminal.h"
209#include "../discovery/strings.h"
210#include "explicit.h"
211
213#define COLOR_MODE_AUTO TERM_COLOR_AUTO
214#define COLOR_MODE_NONE TERM_COLOR_NONE
215#define COLOR_MODE_16 TERM_COLOR_16
216#define COLOR_MODE_16_COLOR TERM_COLOR_16
217#define COLOR_MODE_256 TERM_COLOR_256
218#define COLOR_MODE_256_COLOR TERM_COLOR_256
219#define COLOR_MODE_TRUECOLOR TERM_COLOR_TRUECOLOR
220
239
258
276
285
298#define OPTIONS_BUFF_SIZE 256
299
301#define MAX_IDENTITY_KEYS 32
302
303// ============================================================================
304// GENERAL CATEGORY - General-purpose options (from --help registry)
305// ============================================================================
306
308#define OPT_HELP_DEFAULT false
309
311#define OPT_VERSION_DEFAULT false
312
314#define OPT_SPLASH_DEFAULT true
315
317#define OPT_SPLASH_SCREEN_EXPLICITLY_SET_DEFAULT false
318
320#define OPT_STATUS_SCREEN_DEFAULT true
321
323#define OPT_STATUS_SCREEN_EXPLICITLY_SET_DEFAULT false
324
326#define OPT_ENABLE_KEEPAWAKE_DEFAULT false
327
329#define OPT_DISABLE_KEEPAWAKE_DEFAULT false
330
332#define OPT_NO_CHECK_UPDATE_DEFAULT false
333
334// ============================================================================
335// LOGGING CATEGORY - Binary-level logging and output control options
336// ============================================================================
337
339#define OPT_QUIET_DEFAULT false
340
342#define OPT_VERBOSE_LEVEL_DEFAULT 0
343
345#define OPT_LOG_LEVEL_DEFAULT LOG_INFO
346
348#define OPT_GREP_PATTERN_DEFAULT ""
349
351#define OPT_JSON_DEFAULT false
352
354#define OPT_COLOR_SCHEME_NAME_DEFAULT "pastel"
355
357#define OPT_LOG_TEMPLATE_DEFAULT_RELEASE \
358 "[%color(*, %H):%color(*, %M):%color(*, %S).%color(*, %ms)] [%color(*, %level_aligned)] " \
359 "%colored_message"
360
362#define OPT_LOG_TEMPLATE_DEFAULT_DEBUG \
363 "[%color(*, %H):%color(*, %M):%color(*, %S).%color(*, %ms)] [%color(*, %level_aligned)] " \
364 "[thread/%color(GREY, %tname)] %color(DEBUG, %file_relative):%color(GREY, %line)@%color(DEV, %func)(): " \
365 "%colored_message"
366
372#ifdef NDEBUG
373#define OPT_LOG_TEMPLATE_DEFAULT OPT_LOG_TEMPLATE_DEFAULT_RELEASE
374#else
375#define OPT_LOG_TEMPLATE_DEFAULT OPT_LOG_TEMPLATE_DEFAULT_DEBUG
376#endif
377
379#define OPT_LOG_FORMAT_OUTPUT_DEFAULT LOG_OUTPUT_TEXT
380
382#define OPT_LOG_FORMAT_CONSOLE_DEFAULT false
383
384// ============================================================================
385// TERMINAL CATEGORY - Terminal display options
386// ============================================================================
387
397#define OPT_WIDTH_DEFAULT 110
398
408#define OPT_HEIGHT_DEFAULT 70
409
411#define OPT_AUTO_WIDTH_DEFAULT true
412
414#define OPT_AUTO_HEIGHT_DEFAULT true
415
417#define OPT_COLOR_MODE_DEFAULT COLOR_MODE_AUTO
418
420#define OPT_LIST_WEBCAMS_DEFAULT false
421
423#define OPT_LIST_MICROPHONES_DEFAULT false
424
426#define OPT_LIST_SPEAKERS_DEFAULT false
427
429#define OPT_SHOW_CAPABILITIES_DEFAULT false
430
432#define OPT_FORCE_UTF8_DEFAULT UTF8_SETTING_AUTO
433
435#define OPT_STRIP_ANSI_DEFAULT false
436
438#define OPT_COLOR_DEFAULT COLOR_SETTING_AUTO
439
440// ============================================================================
441// DISPLAY CATEGORY - Display and rendering options
442// ============================================================================
443
445#define OPT_COLOR_FILTER_DEFAULT COLOR_FILTER_NONE
446
448#define OPT_RENDER_MODE_DEFAULT RENDER_MODE_FOREGROUND
449
451#define OPT_PALETTE_TYPE_DEFAULT PALETTE_STANDARD
452
454#define OPT_PALETTE_CUSTOM_SET_DEFAULT false
455
457#define OPT_STRETCH_DEFAULT false
458
460#define OPT_FPS_DEFAULT 60
461
463#define OPT_SNAPSHOT_MODE_DEFAULT false
464
473#if defined(__APPLE__)
474#define OPT_SNAPSHOT_DELAY_DEFAULT 4.0f
475#else
476#define OPT_SNAPSHOT_DELAY_DEFAULT 3.0f
477#endif
478
480#define OPT_MATRIX_RAIN_DEFAULT false
481
483#define OPT_FPS_COUNTER_DEFAULT false
484
487#ifdef __APPLE__
488#define OPT_FLIP_X_DEFAULT true
489#else
490#define OPT_FLIP_X_DEFAULT false
491#endif
492
494#define OPT_FLIP_Y_DEFAULT false
495
496// ============================================================================
497// WEBCAM CATEGORY - Webcam and capture device options
498// ============================================================================
499
501#define OPT_WEBCAM_INDEX_DEFAULT 0
502
504#define OPT_TEST_PATTERN_DEFAULT false
505
507#define OPT_NO_AUDIO_MIXER_DEFAULT false
508
509// ============================================================================
510// MEDIA CATEGORY - Media file streaming and playback options
511// ============================================================================
512
514#define OPT_MEDIA_LOOP_DEFAULT false
515
517#define OPT_MEDIA_FROM_STDIN_DEFAULT false
518
520#define OPT_MEDIA_SEEK_TIMESTAMP_DEFAULT 0.0
521
523#define OPT_PAUSE_DEFAULT false
524
525// ============================================================================
526// NETWORK CATEGORY - Network connectivity and protocol options
527// ============================================================================
528
530#define OPT_ADDRESS_DEFAULT "localhost"
531
533#define OPT_ADDRESS6_DEFAULT "::1"
534
545#ifdef NDEBUG
546#include "../network/acip/acds.h"
547#define OPT_ENDPOINT_DISCOVERY_SERVICE ACDS_OFFICIAL_SERVER_HOSTNAME
548#else
549#define OPT_ENDPOINT_DISCOVERY_SERVICE "localhost"
550#endif
551
553#define OPT_PORT_DEFAULT "27224"
554
556#define OPT_PORT_INT_DEFAULT 27224
557
559#define OPT_WEBSOCKET_PORT_SERVER_DEFAULT 27226
560
562#define OPT_WEBSOCKET_PORT_ACDS_DEFAULT 27227
563
565#define OPT_MAX_CLIENTS_DEFAULT 9
566
568#define OPT_RECONNECT_ATTEMPTS_DEFAULT (-1)
569
571#define OPT_COMPRESSION_LEVEL_DEFAULT 3
572
574#define OPT_NO_COMPRESS_DEFAULT false
575
577#define OPT_ACDS_DEFAULT false
578
580#define OPT_ACDS_PORT_INT_DEFAULT 27225
581
583#define OPT_ACDS_PORT_DEFAULT "27225"
584
586#define OPT_ACDS_EXPOSE_IP_DEFAULT false
587
589#define OPT_ACDS_INSECURE_DEFAULT false
590
592#define OPT_REQUIRE_SERVER_IDENTITY_DEFAULT false
593
595#define OPT_REQUIRE_CLIENT_IDENTITY_DEFAULT false
596
598#define OPT_LAN_DISCOVERY_DEFAULT false
599
601#define OPT_NO_MDNS_ADVERTISE_DEFAULT false
602
604#define OPT_ENABLE_UPNP_DEFAULT false
605
614#define OPT_ENDPOINT_STUN_PRIMARY "stun:stun.ascii-chat.com:3478"
615
617#define OPT_ENDPOINT_STUN_FALLBACK "stun:stun.l.google.com:19302"
618
620#define OPT_ENDPOINT_STUN_SERVERS_DEFAULT OPT_ENDPOINT_STUN_PRIMARY "," OPT_ENDPOINT_STUN_FALLBACK
621
623#define OPT_ENDPOINT_TURN_PRIMARY "turn:turn.ascii-chat.com:3478"
624
626#define OPT_ENDPOINT_TURN_SERVERS_DEFAULT OPT_ENDPOINT_TURN_PRIMARY
627
629#define OPT_STUN_SERVER_HOST_PRIMARY "stun.ascii-chat.com"
630
632#define OPT_STUN_SERVER_PORT_PRIMARY 3478
633
635#define OPT_STUN_SERVER_HOST_FALLBACK "stun.l.google.com"
636
638#define OPT_STUN_SERVER_PORT_FALLBACK 19302
639
641#define OPT_TURN_SERVER_HOST "turn.ascii-chat.com"
642
644#define OPT_TURN_SERVER_PORT 3478
645
647#define OPT_STUN_SERVERS_DEFAULT OPT_ENDPOINT_STUN_SERVERS_DEFAULT
648
650#define OPT_TURN_SERVERS_DEFAULT OPT_ENDPOINT_TURN_SERVERS_DEFAULT
651
655#define OPT_WEBRTC_DEFAULT true
656
658#define OPT_PREFER_WEBRTC_DEFAULT false
659
661#define OPT_NO_WEBRTC_DEFAULT false
662
664#define OPT_WEBRTC_SKIP_STUN_DEFAULT false
665
667#define OPT_WEBRTC_DISABLE_TURN_DEFAULT false
668
670#define OPT_WEBRTC_SKIP_HOST_DEFAULT false
671
673#define OPT_WEBRTC_ICE_TIMEOUT_MS_DEFAULT 10000
674
676#define OPT_WEBRTC_RECONNECT_ATTEMPTS_DEFAULT 3
677
679#define OPT_TURN_USERNAME_DEFAULT ""
680
682#define OPT_TURN_CREDENTIAL_DEFAULT ""
683
684// ============================================================================
685// AUDIO CATEGORY - Audio capture, playback and processing options
686// ============================================================================
687
689#define OPT_AUDIO_ENABLED_DEFAULT true
690
692#define OPT_AUDIO_SOURCE_DEFAULT AUDIO_SOURCE_ALL
694#define OPT_AUDIO_CAPTURE_SOURCE_DEFAULT AUDIO_CAPTURE_SOURCE_AUTO
695
697#define OPT_MICROPHONE_INDEX_DEFAULT (-1)
698
700#define OPT_SPEAKERS_INDEX_DEFAULT (-1)
701
703#define OPT_MICROPHONE_SENSITIVITY_DEFAULT 1.0
704
706#define OPT_SPEAKERS_VOLUME_DEFAULT 1.0
707
709#define OPT_AUDIO_ANALYSIS_ENABLED_DEFAULT false
710
712#define OPT_AUDIO_NO_PLAYBACK_DEFAULT false
713
715#define OPT_ENCODE_AUDIO_DEFAULT true
716
717// ============================================================================
718// SECURITY CATEGORY - Encryption and authentication options
719// ============================================================================
720
722#define OPT_ENCRYPT_ENABLED_DEFAULT true
723
725#define OPT_NO_ENCRYPT_DEFAULT false
726
728#define OPT_NO_AUTH_DEFAULT false
729
731#define OPT_REQUIRE_SERVER_VERIFY_DEFAULT false
732
734#define OPT_REQUIRE_CLIENT_VERIFY_DEFAULT false
735
736// ============================================================================
737// CONFIGURATION CATEGORY - Application configuration options
738// ============================================================================
739
740// (Configuration options are typically handled separately via --config etc.)
741
742// ============================================================================
743// DATABASE CATEGORY - Database and persistent storage options
744// ============================================================================
745
746// (Database options are typically handled separately via --database etc.)
747
748// ============================================================================
749// String Default Values
750// ============================================================================
751
753#define OPT_STRING_EMPTY_DEFAULT ""
754
755// ============================================================================
756// Render-to-file Options
757// ============================================================================
758#define OPT_RENDER_FILE_DEFAULT ""
759#define OPT_RENDER_THEME_DEFAULT 0 // 0=dark, 1=light, 2=auto
760#define OPT_RENDER_FONT_DEFAULT ""
761#define OPT_RENDER_FONT_SIZE_DEFAULT 12.0
762
763// ============================================================================
764// Static Default Value Variables
765// ============================================================================
766// These are referenced from the registry and provide const void * pointers
767// for non-string default values. Defined alongside OPT_*_DEFAULT for clarity.
768
769static const int default_log_level_value = OPT_LOG_LEVEL_DEFAULT;
770static const bool default_quiet_value = OPT_QUIET_DEFAULT;
771static const bool default_json_value = OPT_JSON_DEFAULT;
772static const bool default_enable_keepawake_value = OPT_ENABLE_KEEPAWAKE_DEFAULT;
773static const bool default_disable_keepawake_value = OPT_DISABLE_KEEPAWAKE_DEFAULT;
774static const int default_width_value = OPT_WIDTH_DEFAULT;
775static const int default_height_value = OPT_HEIGHT_DEFAULT;
776static const int default_port_value = OPT_PORT_INT_DEFAULT;
777static const int default_websocket_port_value = OPT_WEBSOCKET_PORT_SERVER_DEFAULT;
778static const int default_webcam_index_value = OPT_WEBCAM_INDEX_DEFAULT;
779static const bool default_flip_x_value = OPT_FLIP_X_DEFAULT;
780static const bool default_flip_y_value = OPT_FLIP_Y_DEFAULT;
781static const bool default_test_pattern_value = OPT_TEST_PATTERN_DEFAULT;
782static const int default_color_value = OPT_COLOR_DEFAULT;
783static const int default_color_mode_value = OPT_COLOR_MODE_DEFAULT;
784static const int default_color_filter_value = OPT_COLOR_FILTER_DEFAULT;
785static const int default_render_mode_value = OPT_RENDER_MODE_DEFAULT;
786static const int default_palette_type_value = OPT_PALETTE_TYPE_DEFAULT;
787static const bool default_show_capabilities_value = OPT_SHOW_CAPABILITIES_DEFAULT;
788static const int default_force_utf8_value = OPT_FORCE_UTF8_DEFAULT;
789static const bool default_stretch_value = OPT_STRETCH_DEFAULT;
790static const bool default_strip_ansi_value = OPT_STRIP_ANSI_DEFAULT;
791static const bool default_snapshot_mode_value = OPT_SNAPSHOT_MODE_DEFAULT;
792static const double default_snapshot_delay_value = OPT_SNAPSHOT_DELAY_DEFAULT;
793static const bool default_matrix_rain_value = OPT_MATRIX_RAIN_DEFAULT;
794static const bool default_waveform_value = false;
795static const bool default_fft_value = false;
796static const bool default_fps_counter_value = OPT_FPS_COUNTER_DEFAULT;
797static const int default_fps_value = OPT_FPS_DEFAULT;
798static const int default_compression_level_value = OPT_COMPRESSION_LEVEL_DEFAULT;
799static const bool default_no_compress_value = OPT_NO_COMPRESS_DEFAULT;
800static const bool default_encrypt_enabled_value = OPT_ENCRYPT_ENABLED_DEFAULT;
801static const bool default_no_encrypt_value = OPT_NO_ENCRYPT_DEFAULT;
802static const bool default_no_auth_value = OPT_NO_AUTH_DEFAULT;
803static const int default_max_clients_value = OPT_MAX_CLIENTS_DEFAULT;
804static const int default_reconnect_attempts_value = OPT_RECONNECT_ATTEMPTS_DEFAULT;
805static const int default_discovery_port_value = OPT_ACDS_PORT_INT_DEFAULT;
806static const bool default_discovery_value = OPT_ACDS_DEFAULT;
807static const bool default_webrtc_value = OPT_WEBRTC_DEFAULT;
808static const bool default_enable_upnp_value = OPT_ENABLE_UPNP_DEFAULT;
809static const bool default_lan_discovery_value = OPT_LAN_DISCOVERY_DEFAULT;
810static const bool default_prefer_webrtc_value = OPT_PREFER_WEBRTC_DEFAULT;
811static const bool default_no_webrtc_value = OPT_NO_WEBRTC_DEFAULT;
812static const bool default_webrtc_skip_stun_value = OPT_WEBRTC_SKIP_STUN_DEFAULT;
813static const bool default_webrtc_relay_only_value = false;
814static const bool default_webrtc_disable_turn_value = OPT_WEBRTC_DISABLE_TURN_DEFAULT;
815static const bool default_webrtc_skip_host_value = OPT_WEBRTC_SKIP_HOST_DEFAULT;
816
817static const int default_webrtc_ice_timeout_ms_value = OPT_WEBRTC_ICE_TIMEOUT_MS_DEFAULT;
818
819static const int default_webrtc_reconnect_attempts_value = OPT_WEBRTC_RECONNECT_ATTEMPTS_DEFAULT;
820static const bool default_media_loop_value = OPT_MEDIA_LOOP_DEFAULT;
821static const bool default_pause_value = OPT_PAUSE_DEFAULT;
822static const double default_media_seek_value = OPT_MEDIA_SEEK_TIMESTAMP_DEFAULT;
823static const bool default_audio_enabled_value = OPT_AUDIO_ENABLED_DEFAULT;
824static const audio_source_t default_audio_source_value = OPT_AUDIO_SOURCE_DEFAULT;
825static const audio_capture_source_t default_audio_capture_source_value = OPT_AUDIO_CAPTURE_SOURCE_DEFAULT;
826static const int default_microphone_index_value = OPT_MICROPHONE_INDEX_DEFAULT;
827static const int default_speakers_index_value = OPT_SPEAKERS_INDEX_DEFAULT;
828static const double default_microphone_sensitivity_value = OPT_MICROPHONE_SENSITIVITY_DEFAULT;
829static const double default_speakers_volume_value = OPT_SPEAKERS_VOLUME_DEFAULT;
830static const bool default_audio_analysis_value = OPT_AUDIO_ANALYSIS_ENABLED_DEFAULT;
831static const bool default_no_audio_playback_value = OPT_AUDIO_NO_PLAYBACK_DEFAULT;
832static const bool default_encode_audio_value = OPT_ENCODE_AUDIO_DEFAULT;
833static const bool default_no_encode_audio_value = !OPT_ENCODE_AUDIO_DEFAULT;
834static const bool default_no_audio_mixer_value = OPT_NO_AUDIO_MIXER_DEFAULT;
835static const bool default_discovery_expose_ip_value = OPT_ACDS_EXPOSE_IP_DEFAULT;
836static const bool default_discovery_insecure_value = OPT_ACDS_INSECURE_DEFAULT;
837static const bool default_require_server_identity_value = OPT_REQUIRE_SERVER_IDENTITY_DEFAULT;
838static const bool default_require_client_identity_value = OPT_REQUIRE_CLIENT_IDENTITY_DEFAULT;
839static const bool default_splash_value = OPT_SPLASH_DEFAULT;
840static const bool default_splash_false = false; // For --no-splash-screen option
841static const bool default_status_screen_value = OPT_STATUS_SCREEN_DEFAULT;
842static const bool default_no_check_update_value = OPT_NO_CHECK_UPDATE_DEFAULT;
843static const bool default_log_format_console_only_value = OPT_LOG_FORMAT_CONSOLE_DEFAULT;
844
845#ifndef NDEBUG
846static const double default_debug_sync_state_time_value = 0.0;
847static const bool default_debug_sync_state_time_explicit_value = false;
848static const double default_debug_backtrace_time_value = 0.0;
849static const bool default_debug_backtrace_time_explicit_value = false;
850static const double default_debug_memory_report_interval_value = 0.0;
851static const bool default_debug_memory_report_interval_explicit_value = false;
852#endif
853
854static const int default_render_theme_value = OPT_RENDER_THEME_DEFAULT;
855static const double default_render_font_size_value = OPT_RENDER_FONT_SIZE_DEFAULT;
856
898int strtoint_safe(const char *str);
899
915
932
939#define OPTION_MODE_SERVER_LIKE (OPTION_MODE_SERVER | OPTION_MODE_DISCOVERY_SVC)
940#define OPTION_MODE_CLIENT_LIKE (OPTION_MODE_CLIENT | OPTION_MODE_MIRROR | OPTION_MODE_DISCOVERY)
941#define OPTION_MODE_NETWORKED \
942 (OPTION_MODE_SERVER | OPTION_MODE_CLIENT | OPTION_MODE_DISCOVERY_SVC | OPTION_MODE_DISCOVERY)
943
950typedef struct options_state {
951 // ============================================================================
952 // Mode Detection (auto-detected during options_init)
953 // ============================================================================
955
956 // ============================================================================
957 // Binary-Level Options (parsed first, before mode selection)
958 // ============================================================================
959 bool help;
960 bool version;
962
963 // ============================================================================
964 // Terminal Dimensions
965 // ============================================================================
966 int width;
967 int height;
970
971 // ============================================================================
972 // Network Options
973 // ============================================================================
976 int port;
984
985 // ============================================================================
986 // Discovery Service Options (server only)
987 // ============================================================================
995 bool webrtc;
998
999 // ============================================================================
1000 // LAN Discovery Options
1001 // ============================================================================
1004
1005 // ============================================================================
1006 // Network Performance Options
1007 // ============================================================================
1011
1012 // ============================================================================
1013 // Client Reconnection Options
1014 // ============================================================================
1016
1017 // ============================================================================
1018 // Webcam Options
1019 // ============================================================================
1023
1024 // ============================================================================
1025 // Media File Streaming Options
1026 // ============================================================================
1032 bool pause;
1033 char yt_dlp_options[512];
1034
1035 // ============================================================================
1036 // Display Options
1037 // ============================================================================
1038 int color;
1045 int fps;
1047 bool flip_x;
1048 bool flip_y;
1049
1050 // ============================================================================
1051 // Audio Configuration
1052 // ============================================================================
1057 bool fft;
1064
1065 // ============================================================================
1066 // Image Options
1067 // ============================================================================
1068 bool stretch;
1069 char video_codec[64];
1070
1071 // ============================================================================
1072 // Output Options
1073 // ============================================================================
1074 bool quiet;
1075 unsigned short int verbose_level;
1084 bool json;
1089
1090 // ============================================================================
1091 // Encryption Options
1092 // ============================================================================
1098 bool no_auth;
1101
1102 // Multi-key support: When multiple --key flags are provided, all keys are stored here
1103 // encrypt_key is duplicated in identity_keys[0] for backward compatibility
1107
1108 // ============================================================================
1109 // Identity Verification Options (ACDS + Crypto Handshake)
1110 // ============================================================================
1117
1118 // ============================================================================
1119 // WebRTC Connection Strategy Options (client-side fallback control)
1120 // ============================================================================
1129
1130 // ============================================================================
1131 // WebRTC Connectivity Options (ACDS mode only)
1132 // ============================================================================
1139
1140 // ============================================================================
1141 // Palette Configuration
1142 // ============================================================================
1144 char palette_custom[256];
1146
1147 // ============================================================================
1148 // Splash Screen Options
1149 // ============================================================================
1155
1156 // ============================================================================
1157 // Debug Options (Debug builds only)
1158 // ============================================================================
1159#ifndef NDEBUG
1166#endif
1167
1168 // ============================================================================
1169 // Render-to-file options
1170 // ============================================================================
1175
1176 // Note: Luminance weights (weight_red, weight_green, weight_blue) and
1177 // lookup tables (RED[], GREEN[], BLUE[], GRAY[]) are kept as globals
1178 // since they're precomputed constants, not user-configurable options.
1180
1181// ============================================================================
1182// RCU-based thread-safe options access
1183// ============================================================================
1184
1195const options_t *options_get(void);
1196
1235#define GET_OPTION(field) \
1236 ({ \
1237 const options_t *_opts = options_get(); \
1238 if (!_opts) { \
1239 log_warn("GET_OPTION(" #field ") called but options not initialized"); \
1240 } \
1241 static typeof(((options_t *)0)->field) _default = {0}; \
1242 (_opts ? (_opts->field) : _default); \
1243 })
1244
1290asciichat_error_t options_set_int(const char *field_name, int value);
1291asciichat_error_t options_set_bool(const char *field_name, bool value);
1292asciichat_error_t options_set_string(const char *field_name, const char *value);
1293asciichat_error_t options_set_double(const char *field_name, double value);
1294
1319const char *options_get_help_text(asciichat_mode_t mode, const char *option_name);
1320
1327extern const float weight_red;
1328
1337extern const float weight_green;
1338
1347extern const float weight_blue;
1348
1363extern unsigned short int RED[];
1364
1371extern unsigned short int GREEN[];
1372
1379extern unsigned short int BLUE[];
1380
1388extern unsigned short int GRAY[];
1389
1402bool has_action_flag(void);
1403
1509
1656asciichat_error_t options_init(int argc, char **argv);
1657
1700void usage(FILE *stream, asciichat_mode_t mode);
1701
1745
1782
1788extern uint64_t g_snapshot_first_frame_rendered_ns; // Timestamp when first frame was rendered (nanoseconds)
1789extern uint64_t g_snapshot_first_capture_ns; // Timestamp when first frame was captured (nanoseconds)
1790extern uint64_t g_snapshot_actual_duration_ms; // Actual wall-clock duration in ms when snapshot timeout reached
1791
Check if an option was explicitly set via command-line.
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
log_level_t
Logging levels enumeration.
Definition types.h:29
utf8_setting_t
UTF-8 support setting (–utf8 flag values)
#define OPT_STRIP_ANSI_DEFAULT
Default strip ANSI escape sequences flag.
#define OPT_WEBRTC_SKIP_STUN_DEFAULT
Default WebRTC skip STUN flag (false = use STUN)
#define OPT_ACDS_EXPOSE_IP_DEFAULT
Default ACDS expose IP flag (false = private by default)
unsigned short int GRAY[]
Grayscale lookup table.
const char * options_get_help_text(asciichat_mode_t mode, const char *option_name)
Get help text for an option in a specific mode.
Definition help_api.c:27
#define MAX_IDENTITY_KEYS
Maximum number of identity keys that can be loaded (for multi-key support)
unsigned short int BLUE[]
Blue channel lookup table.
#define OPT_COLOR_DEFAULT
Default color setting (COLOR_SETTING_AUTO = smart detection)
#define OPT_NO_AUDIO_MIXER_DEFAULT
Default no audio mixer flag (false = enable mixer)
#define OPT_FLIP_Y_DEFAULT
Default vertical flip state (false = no vertical flip)
#define OPT_SHOW_CAPABILITIES_DEFAULT
Default show terminal capabilities flag.
#define OPT_NO_ENCRYPT_DEFAULT
Default no encrypt flag (false = allow encryption)
#define OPT_QUIET_DEFAULT
Default quiet mode flag (false = logging enabled)
asciichat_mode_t
Mode type for options parsing.
asciichat_error_t options_set_int(const char *field_name, int value)
Check if an option was explicitly set via command-line.
Definition rcu.c:761
#define OPT_MICROPHONE_INDEX_DEFAULT
Default microphone device index (-1 means system default)
struct options_state options_t
Consolidated options structure.
#define OPT_ENCODE_AUDIO_DEFAULT
Default audio encoding state (true = Opus encoding enabled)
#define OPT_COLOR_MODE_DEFAULT
Default color mode (auto-detect terminal capabilities)
#define OPT_PALETTE_TYPE_DEFAULT
Default palette type (standard ASCII art)
#define OPT_RECONNECT_ATTEMPTS_DEFAULT
Default reconnect attempts (-1 means auto/infinite)
#define OPT_SPEAKERS_VOLUME_DEFAULT
Default speakers volume (1.0 = normal volume)
int strtoint_safe(const char *str)
Safely parse string to integer with validation.
void update_dimensions_to_terminal_size(options_t *opts)
Update dimensions to match current terminal size.
#define OPT_NO_AUTH_DEFAULT
Default no auth flag (false = allow authentication)
#define OPT_TEST_PATTERN_DEFAULT
Default test pattern mode (false = use actual webcam)
#define OPT_WEBRTC_ICE_TIMEOUT_MS_DEFAULT
Default WebRTC ICE gathering timeout in milliseconds (10 seconds)
#define OPT_COMPRESSION_LEVEL_DEFAULT
Default compression level (1-9)
#define OPT_ENCRYPT_ENABLED_DEFAULT
Default encrypt enabled flag (true = encryption required)
#define OPT_REQUIRE_SERVER_IDENTITY_DEFAULT
Default require-server-identity setting for ACDS.
#define OPT_ENABLE_KEEPAWAKE_DEFAULT
Default keep-awake (prevent system sleep) flag (false = normal system sleep)
#define OPT_RENDER_MODE_DEFAULT
Default render mode (foreground characters only)
#define OPT_ACDS_PORT_INT_DEFAULT
Default ACDS discovery service port (integer)
#define OPT_AUDIO_ENABLED_DEFAULT
Default audio enabled flag (true = audio enabled by default)
#define OPT_MATRIX_RAIN_DEFAULT
Default Matrix rain effect flag (false = disabled)
#define OPT_FORCE_UTF8_DEFAULT
Default force UTF-8 support setting (auto-detect)
const float weight_blue
Blue weight for luminance calculation.
#define OPT_RENDER_FONT_SIZE_DEFAULT
#define OPT_WEBRTC_RECONNECT_ATTEMPTS_DEFAULT
Default WebRTC reconnection attempts (3 = try initial + 3 retries)
#define OPT_SPLASH_DEFAULT
Default splash screen flag (true = show splash, false = hide splash)
#define OPT_RENDER_THEME_DEFAULT
#define OPT_FPS_COUNTER_DEFAULT
Default FPS counter overlay flag (false = disabled)
#define OPT_AUDIO_ANALYSIS_ENABLED_DEFAULT
Default audio analysis enabled flag.
asciichat_error_t options_set_double(const char *field_name, double value)
Definition rcu.c:1283
const options_t * options_get(void)
Get current options (lock-free read)
Definition rcu.c:496
const float weight_red
Red weight for luminance calculation.
#define OPT_ACDS_DEFAULT
Default ACDS registration flag (false = disabled)
#define OPTIONS_BUFF_SIZE
Buffer size for option string values.
#define OPT_NO_COMPRESS_DEFAULT
Default no compression flag (false = enable compression)
asciichat_error_t options_init(int argc, char **argv)
Initialize options by parsing command-line arguments with unified mode detection.
audio_source_t
Audio source selected for visualization.
option_mode_bitmask_t
Option mode bitmask.
#define OPT_AUDIO_NO_PLAYBACK_DEFAULT
Default audio playback flag (false = enable playback)
#define OPT_PAUSE_DEFAULT
Default pause media flag (false = play immediately)
#define OPT_AUDIO_SOURCE_DEFAULT
Visualize all available sources by default.
asciichat_error_t options_set_string(const char *field_name, const char *value)
Definition rcu.c:1186
asciichat_error_t options_set_bool(const char *field_name, bool value)
Definition rcu.c:969
#define OPT_COLOR_FILTER_DEFAULT
Default color filter (none - no filtering)
#define OPT_WEBCAM_INDEX_DEFAULT
Default webcam device index.
void usage(FILE *stream, asciichat_mode_t mode)
Print usage information for a specific mode.
#define OPT_HEIGHT_DEFAULT
Default terminal height in characters.
unsigned short int GREEN[]
Green channel lookup table.
#define OPT_SNAPSHOT_MODE_DEFAULT
Default snapshot mode flag (false = continuous)
#define OPT_MEDIA_LOOP_DEFAULT
Default loop media flag (false = play once)
#define OPT_NO_CHECK_UPDATE_DEFAULT
Default no-check-update flag (false = check for updates enabled)
#define OPT_STRETCH_DEFAULT
Default allow aspect ratio distortion flag.
#define OPT_STATUS_SCREEN_DEFAULT
Default status screen flag (true = show status, false = hide status)
#define OPT_LAN_DISCOVERY_DEFAULT
Default LAN discovery flag (false = discovery disabled)
#define OPT_JSON_DEFAULT
Default JSON logging flag (false = text output)
#define OPT_ACDS_INSECURE_DEFAULT
Default ACDS insecure mode flag (false = verify server)
bool has_action_flag(void)
Check if an action flag was detected.
#define OPT_FPS_DEFAULT
Default FPS (frames per second)
#define OPT_WEBRTC_DEFAULT
Default WebRTC mode flag (true = P2P WebRTC, false = direct TCP)
#define OPT_REQUIRE_CLIENT_IDENTITY_DEFAULT
Default require-client-identity setting for ACDS.
color_setting_t
Color output setting (–color flag values)
#define OPT_DISABLE_KEEPAWAKE_DEFAULT
Default disable keep-awake flag (false = allow system sleep prevention)
#define OPT_ENABLE_UPNP_DEFAULT
Default enable UPnP flag (false = UPnP disabled)
#define OPT_WEBRTC_SKIP_HOST_DEFAULT
Default WebRTC skip host candidates flag (false = use host candidates)
#define OPT_LOG_FORMAT_CONSOLE_DEFAULT
Default log format console only flag (false = use default format everywhere)
#define OPT_SNAPSHOT_DELAY_DEFAULT
Default snapshot delay in seconds.
const float weight_green
Green weight for luminance calculation.
#define OPT_LOG_LEVEL_DEFAULT
Default log level (LOG_INFO)
#define OPT_MICROPHONE_SENSITIVITY_DEFAULT
Default microphone sensitivity (1.0 = normal volume)
#define OPT_FLIP_X_DEFAULT
Default horizontal flip state (true = horizontally flipped) macOS webcams default to flipped (mirrore...
#define OPT_PORT_INT_DEFAULT
Default TCP port for client/server communication (integer)
unsigned short int RED[]
Red channel lookup table.
#define OPT_MAX_CLIENTS_DEFAULT
Default maximum concurrent clients (server only)
#define OPT_PREFER_WEBRTC_DEFAULT
Default prefer WebRTC flag (false = try direct TCP first)
options_t options_t_new(void)
Initialize options by parsing command-line arguments.
#define OPT_WEBRTC_DISABLE_TURN_DEFAULT
Default WebRTC disable TURN flag (false = use TURN)
#define OPT_NO_WEBRTC_DEFAULT
Default no WebRTC flag (false = WebRTC enabled)
#define OPT_AUDIO_CAPTURE_SOURCE_DEFAULT
Preserve automatic local audio capture selection by default.
#define OPT_SPEAKERS_INDEX_DEFAULT
Default speakers device index (-1 means system default)
void update_dimensions_for_full_height(options_t *opts)
Update dimensions to use full terminal height while maintaining aspect ratio.
#define OPT_WEBSOCKET_PORT_SERVER_DEFAULT
Default WebSocket port for server mode (integer)
#define OPT_MEDIA_SEEK_TIMESTAMP_DEFAULT
Default media seek timestamp (start from beginning)
#define OPT_WIDTH_DEFAULT
Default terminal width in characters.
@ UTF8_SETTING_AUTO
Smart detection (default): UTF-8 if terminal supports it.
@ UTF8_SETTING_FALSE
Force UTF-8 OFF: disable UTF-8 support.
@ UTF8_SETTING_TRUE
Force UTF-8 ON: always use UTF-8 regardless of terminal capability.
@ MODE_CLIENT
Client mode - network client options.
@ MODE_DISCOVERY_SERVICE
Discovery server mode - session management and WebRTC signaling.
@ MODE_INVALID
Invalid mode.
@ MODE_SERVER
Server mode - network server options.
@ MODE_MIRROR
Mirror mode - local webcam viewing (no network)
@ MODE_DISCOVERY
Discovery mode - participant that can dynamically become host.
@ OPTION_MODE_ALL
All modes + binary.
@ OPTION_MODE_BINARY
Binary-level options (parsed before mode detection)
@ OPTION_MODE_CLIENT
Client mode (bit 1)
@ OPTION_MODE_DISCOVERY
Discovery mode (bit 4)
@ OPTION_MODE_SERVER
Server mode (bit 0)
@ OPTION_MODE_MIRROR
Mirror mode (bit 2)
@ OPTION_MODE_NONE
No modes (invalid)
@ OPTION_MODE_DISCOVERY_SVC
Discovery server mode (bit 3)
@ COLOR_SETTING_TRUE
Force colors ON: always colorize regardless of TTY/piping/CLAUDECODE.
@ COLOR_SETTING_FALSE
Force colors OFF: disable all colors and logging colors.
@ COLOR_SETTING_AUTO
Smart detection (default): colors if TTY and not CLAUDECODE and not piping.
palette_type_t
Built-in palette type enumeration.
Definition palette.h:84
bool g_snapshot_first_frame_rendered
Snapshot mode global timing variables Used to track actual duration when snapshot mode is active.
uint64_t g_snapshot_first_frame_rendered_ns
uint64_t g_snapshot_first_capture_ns
uint64_t g_snapshot_actual_duration_ms
ASCII Palette Management for Video-to-ASCII Conversion.
ClangTool/LibTooling compatibility shim for stdbool.h.
#define SESSION_STRING_BUFFER_SIZE
Consolidated options structure.
bool snapshot_mode
Snapshot mode (one frame and exit)
bool splash_screen_explicitly_set
True if splash screen was explicitly set by user.
float speakers_volume
Speaker volume multiplier (0.0-1.0, default 1.0)
int discovery_port
discovery server port (default: 27225)
char media_url[256]
Network URL (HTTP/HTTPS/YouTube/RTSP) - takes priority over media_file.
size_t num_identity_keys
Number of identity keys loaded (0 means single-key mode using encrypt_key)
bool webrtc
Enable WebRTC mode for discovery session (default: true, P2P WebRTC)
audio_capture_source_t audio_capture_source
Local capture/media selection policy.
bool encrypt_enabled
Enable encryption.
char websocket_tls_key_password[256]
WebSocket TLS key password (server/discovery-service only)
terminal_color_mode_t color_mode
Color mode (auto/none/16/256/truecolor)
bool discovery_expose_ip
ACDS: explicitly allow public IP disclosure without verification (opt-in)
char turn_servers[256]
ACDS: Comma-separated list of TURN server URLs.
int force_utf8
UTF-8 support setting (auto/true/false)
int webrtc_ice_timeout_ms
–webrtc-ice-timeout: ICE gathering timeout in milliseconds (default: 10000)
bool debug_backtrace_time_explicit
True if –backtrace was explicitly provided.
bool discovery
Enable discovery session registration (default: false)
char render_font[256]
Font family name or .ttf path (empty = platform default)
double debug_memory_report_interval
Interval in seconds for periodic memory reports (debug builds only)
char discovery_service_url[256]
exclusive with discovery_port)
bool webrtc_relay_only
–webrtc-relay-only: Require TURN relay candidates
bool disable_keepawake
Explicitly disable system sleep prevention (allow OS to sleep)
bool debug_sync_state_time_explicit
True if –debug-state was explicitly provided.
char log_template[256]
Custom log format string (formerly –log-format)
float microphone_sensitivity
Microphone volume multiplier (0.0-1.0, default 1.0)
int compression_level
zstd compression level (1-9)
bool fps_explicitly_set
True if FPS was explicitly configured by the user.
bool fft
Replace the video image with a live audio frequency spectrogram.
bool enable_keepawake
Explicitly enable system sleep prevention.
double debug_sync_state_time
Time parameter for –sync-state option (debug builds only)
bool show_capabilities
Show terminal capabilities and exit.
bool no_mdns_advertise
Disable mDNS service advertisement (server only)
bool fps_counter
Show FPS counter overlay in top-right corner.
char password[256]
Password string.
int microphone_index
Microphone device index (-1 = default)
char config_file[256]
Config file path (–config)
asciichat_mode_t detected_mode
Mode detected from command-line arguments.
bool strip_ansi
Strip ANSI escape sequences.
bool audio_analysis_enabled
Enable audio analysis (debug)
int websocket_port
WebSocket server port (server/discovery-service only)
bool pause
Start playback paused (toggle with spacebar)
audio_source_t audio_source
Visualization source (all/call/mic/media)
bool json
Enable JSON logging (–json flag)
char stun_servers[256]
ACDS: Comma-separated list of STUN server URLs.
int height
Terminal height in characters (int for OPTION_TYPE_INT compat)
bool enable_upnp
Enable UPnP/NAT-PMP port mapping for direct TCP (opt-in via –upnp)
bool webrtc_skip_stun
–webrtc-skip-stun: Skip Stage 2 (STUN), go to TURN
bool debug_memory_report_interval_explicit
True if –memory-report was explicitly provided.
char websocket_tls_cert[256]
WebSocket TLS certificate file path (server/discovery-service only)
bool log_format_console_only
Apply log format only to console output.
bool lan_discovery
Enable LAN service discovery via mDNS (client only)
char websocket_tls_key[256]
WebSocket TLS private key file path (server/discovery-service only)
char identity_keys[32][256]
All identity keys (populated when –key is used multiple times)
bool audio_enabled
Enable audio streaming.
bool no_encrypt
Disable encryption (opt-out)
bool no_webrtc
–no-webrtc: Disable WebRTC, use Direct TCP only
bool matrix_rain
Matrix digital rain effect (false = disabled)
bool webrtc_disable_turn
–webrtc-disable-turn: Disable Stage 3 (TURN), use STUN only
bool audio_no_playback
Disable speaker playback (debug)
bool auto_height
Auto-detect height from terminal.
log_level_t log_level
Log level threshold.
char render_file[256]
Output file path (e.g. output.mp4)
char turn_credential[256]
ACDS: Credential/password for TURN authentication.
bool require_server_identity
ACDS: require servers to provide signed Ed25519 identity.
char palette_custom[256]
Custom palette characters.
bool status_screen
Show status screen (default: true = show, use –no-status-screen to hide)
int max_clients
Maximum concurrent clients (server only)
bool palette_custom_set
True if custom palette was set.
render_mode_t render_mode
Render mode (foreground/background/half-block)
bool no_auth
Disable authentication layer (–no-auth)
bool splash_screen
Show splash screen (default: true = show, use –no-splash-screen to hide)
char discovery_database_path[256]
~/.ascii-chat/discovery.db)
char server_key[256]
Expected server public key (client)
bool no_audio_mixer
Disable audio mixer (debug)
char encrypt_keyfile[256]
Alternative key file path.
bool webrtc_skip_host
–webrtc-skip-host: Skip host candidates, force STUN/TURN only
bool version
Show version information.
int webcam_index
Webcam device index (0 = first)
bool status_screen_explicitly_set
True if status_screen was explicitly set by user.
bool no_compress
Disable compression entirely.
int webrtc_reconnect_attempts
–webrtc-reconnect-attempts: Number of retry attempts (default: 3)
char address6[256]
IPv6 bind address (server only)
int speakers_index
Speakers device index (-1 = default)
color_filter_t color_filter
Monochromatic color filter (none/black/white/green/etc)
bool prefer_webrtc
–prefer-webrtc: Try WebRTC before Direct TCP
bool quiet
Quiet mode (suppress logs)
double snapshot_delay
Snapshot delay in seconds.
int fps
Target framerate (1-144, default: 60)
bool stretch
Allow aspect ratio distortion.
bool waveform
Replace the video image with a live audio waveform.
int reconnect_attempts
Number of reconnection attempts (-1=infinite, 0=none)
bool test_pattern
Use test pattern instead of webcam.
char video_codec[64]
Video codec (raw, hevc) - default: hevc.
bool media_from_stdin
Reading from stdin (detected from "--file -")
char yt_dlp_options[512]
Arbitrary yt-dlp options (e.g., "--cookies-from-browser=chrome --embed-subs")
bool require_client_verify
Client: only connect to servers whose identity was verified by ACDS.
char discovery_server[256]
discovery server address (default: 127.0.0.1)
double debug_backtrace_time
Time parameter for –backtrace option (debug builds only)
int width
Terminal width in characters (int for OPTION_TYPE_INT compat)
bool require_server_verify
Server: only accept clients who verified via ACDS.
palette_type_t palette_type
Selected palette type.
bool flip_y
Flip video vertically (Y-axis)
char color_scheme_name[64]
Color scheme name (e.g., "pastel", "nord")
char turn_secret[256]
ACDS: Shared secret for dynamic TURN credential generation (HMAC-SHA1)
bool media_loop
Loop media file playback.
char discovery_service_key[256]
HTTPS URL)
bool require_client_identity
ACDS: require clients to provide signed Ed25519 identity.
bool discovery_insecure
ACDS: skip server key verification (MITM-vulnerable, requires explicit opt-in)
bool no_check_update
Disable automatic update checks (default: false = checks enabled)
bool encode_audio
Enable Opus audio encoding.
int render_theme
0=dark 1=light 2=auto
char encrypt_key[256]
SSH/GPG key file path (first –key flag, kept for compatibility)
char media_file[256]
Media file path or "-" for stdin.
int color
Color setting (COLOR_SETTING_AUTO/TRUE/FALSE)
char turn_username[256]
ACDS: Username for TURN authentication.
char log_file[256]
Log file path.
unsigned short int verbose_level
Verbosity level (stackable -V)
char address[256]
Server address (client) or bind address (server)
bool flip_x
Flip video horizontally (X-axis). Ignored for webcam on macOS.
char grep_pattern[256]
PCRE2 regex for log filtering.
bool auto_width
Auto-detect width from terminal.
char client_keys[256]
Allowed client keys (server)
double render_font_size
Font size in points (default 12.0, supports e.g. 10.5)
double media_seek_timestamp
Seek to timestamp in seconds before playback.
color_filter_t
Monochromatic color filter enumeration.
Definition terminal.h:599
render_mode_t
Render mode preferences.
Definition terminal.h:662
terminal_color_mode_t
Terminal color support levels.
Definition terminal.h:578