ascii-chat
Binary v0.15.83-53-gb711d8720
Library lib/v0.3.2-701-gb711d8720
Video chat in your terminal
Loading...
Searching...
No Matches
options.h File Reference

⚙️ Unified options parsing system for ascii-chat with builder pattern and lock-free access More...

Go to the source code of this file.

Data Structures

struct  options_state
 Immutable, RCU-published snapshot of the application's runtime configuration. More...

Macros

#define OPTIONS_YT_DLP_OPTIONS_BUFFER_SIZE   512
#define OPTIONS_COLOR_SCHEME_NAME_BUFFER_SIZE   64
#define OPTIONS_VIDEO_CODEC_BUFFER_SIZE   64
#define OPTIONS_PALETTE_CUSTOM_BUFFER_SIZE   256
#define COLOR_MODE_AUTO   TERM_COLOR_AUTO
 Backward compatibility aliases for color mode enum values.
#define COLOR_MODE_NONE   TERM_COLOR_NONE
 Monochrome mode.
#define COLOR_MODE_16   TERM_COLOR_16
 16-color mode (alias)
#define COLOR_MODE_16_COLOR   TERM_COLOR_16
 16-color mode (full name)
#define COLOR_MODE_256   TERM_COLOR_256
 256-color mode (alias)
#define COLOR_MODE_256_COLOR   TERM_COLOR_256
 256-color mode (full name)
#define COLOR_MODE_TRUECOLOR   TERM_COLOR_TRUECOLOR
 24-bit truecolor mode
#define OPT_WEBRTC_DEFAULT   true
 Default WebRTC mode flag (true = P2P WebRTC, false = direct TCP).
#define OPT_PREFER_WEBRTC_DEFAULT   false
 Default prefer WebRTC flag (false = try direct TCP first).
#define OPT_NO_WEBRTC_DEFAULT   false
 Default no WebRTC flag (false = WebRTC enabled).
#define OPT_WEBRTC_SKIP_STUN_DEFAULT   false
 Default WebRTC skip STUN flag (false = use STUN).
#define OPT_WEBRTC_DISABLE_TURN_DEFAULT   false
 Default WebRTC disable TURN flag (false = use TURN).
#define OPT_WEBRTC_SKIP_HOST_DEFAULT   false
 Default WebRTC skip host candidates flag (false = use host candidates).
#define OPT_WEBRTC_ICE_TIMEOUT_MS_DEFAULT   10000
 Default WebRTC ICE gathering timeout in milliseconds (10 seconds).
#define OPT_WEBRTC_RECONNECT_ATTEMPTS_DEFAULT   3
 Default WebRTC reconnection attempts (3 = try initial + 3 retries).
#define OPT_TURN_USERNAME_DEFAULT   ""
 Default TURN username (empty = use ACDS credentials).
#define OPT_TURN_CREDENTIAL_DEFAULT   ""
 Default TURN credential (empty = use ACDS credentials).
#define OPT_AUDIO_ENABLED_DEFAULT   true
 Default audio enabled flag (true = audio enabled by default).
#define OPT_AUDIO_SOURCE_DEFAULT   AUDIO_SOURCE_ALL
 Visualize all available sources by default.
#define OPT_AUDIO_CAPTURE_SOURCE_DEFAULT   AUDIO_CAPTURE_SOURCE_AUTO
 Preserve automatic local audio capture selection by default.
#define OPT_MICROPHONE_INDEX_DEFAULT   (-1)
 Default microphone device index (-1 means system default).
#define OPT_SPEAKERS_INDEX_DEFAULT   (-1)
 Default speakers device index (-1 means system default).
#define OPT_MICROPHONE_SENSITIVITY_DEFAULT   1.0
 Default microphone sensitivity (1.0 = normal volume).
#define OPT_SPEAKERS_VOLUME_DEFAULT   1.0
 Default speakers volume (1.0 = normal volume).
#define OPT_AUDIO_ANALYSIS_ENABLED_DEFAULT   false
 Default audio analysis enabled flag.
#define OPT_AUDIO_NO_PLAYBACK_DEFAULT   false
 Default audio playback flag (false = enable playback).
#define OPT_ENCODE_AUDIO_DEFAULT   true
 Default audio encoding state (true = Opus encoding enabled).
#define OPT_ENCRYPT_ENABLED_DEFAULT   false
 Default encrypt enabled flag (true = encryption required).
#define OPT_NO_ENCRYPT_DEFAULT   false
 Default no encrypt flag (false = allow encryption).
#define OPT_NO_AUTH_DEFAULT   false
 Default no auth flag (false = allow authentication).
#define OPT_REQUIRE_SERVER_VERIFY_DEFAULT   false
 Default require server verify flag (false = not required).
#define OPT_REQUIRE_CLIENT_VERIFY_DEFAULT   false
 Default require client verify flag (false = not required).
#define OPT_STRING_EMPTY_DEFAULT   ""
 Default empty string for string option fields that have no configured value.
#define OPT_RENDER_FILE_DEFAULT   ""
#define OPT_RENDER_THEME_DEFAULT   0
#define OPT_RENDER_FONT_DEFAULT   ""
#define OPT_RENDER_FONT_SIZE_DEFAULT   0.0
#define OPTION_MODE_SERVER_LIKE   (OPTION_MODE_SERVER | OPTION_MODE_DISCOVERY_SVC)
 Mode group macros for examples.
#define OPTION_MODE_CLIENT_LIKE   (OPTION_MODE_CLIENT | OPTION_MODE_MIRROR | OPTION_MODE_DISCOVERY)
#define OPTION_MODE_NETWORKED    (OPTION_MODE_SERVER | OPTION_MODE_CLIENT | OPTION_MODE_DISCOVERY_SVC | OPTION_MODE_DISCOVERY)
#define ASCII_RENDERER_DEFAULT   ASCII_RENDERER_GLYPH
#define options_terminal_settings()
#define GET_OPTION(field)
 Safely get a specific option field (lock-free read).
Configuration Constants
#define OPTIONS_BUFF_SIZE   256
 Buffer size for option string values.
#define OPT_HELP_DEFAULT   false
 Default help flag (false = don't show help).
#define OPT_VERSION_DEFAULT   false
 Default version flag (false = don't show version).
#define OPT_SPLASH_DEFAULT   true
 Default splash screen flag (true = show splash, false = hide splash).
#define OPT_SPLASH_SCREEN_EXPLICITLY_SET_DEFAULT   false
 Default splash screen explicitly set flag (false = use default splash setting).
#define OPT_STATUS_SCREEN_DEFAULT   true
 Default status screen flag (true = show status, false = hide status).
#define OPT_STATUS_SCREEN_EXPLICITLY_SET_DEFAULT   false
 Default status screen explicitly set flag (false = use default status screen setting).
#define OPT_ENABLE_KEEPAWAKE_DEFAULT   false
 Default keep-awake (prevent system sleep) flag (false = normal system sleep).
#define OPT_DISABLE_KEEPAWAKE_DEFAULT   false
 Default disable keep-awake flag (false = allow system sleep prevention).
#define OPT_NO_CHECK_UPDATE_DEFAULT   false
 Default no-check-update flag (false = check for updates enabled).
#define OPT_QUIET_DEFAULT   false
 Default quiet mode flag (false = logging enabled).
#define OPT_OTEL_ENDPOINT_DEFAULT   ""
 Debug and Dev builds export to the local Spaniel Compose collector.
#define OPT_VERBOSE_LEVEL_DEFAULT   0
 Default verbose level (0 = not verbose).
#define OPT_LOG_LEVEL_DEFAULT   LOG_INFO
 Default log level (LOG_INFO).
#define OPT_GREP_PATTERN_DEFAULT   ""
 Default grep pattern (empty = no filtering).
#define OPT_JSON_DEFAULT   false
 Default JSON logging flag (false = text output).
#define OPT_COLOR_SCHEME_NAME_DEFAULT   "pastel"
 Default color scheme name (pastel).
#define OPT_LOG_TEMPLATE_DEFAULT_RELEASE
 Default log format string - release mode (simple format with timestamp, level, and message).
#define OPT_LOG_TEMPLATE_DEFAULT_DEBUG
 Default log format string - debug mode (verbose with thread name, file relative path, line, and function).
#define OPT_LOG_TEMPLATE_DEFAULT   OPT_LOG_TEMPLATE_DEFAULT_DEBUG
 Default log template string (selected based on build mode).
#define OPT_LOG_FORMAT_OUTPUT_DEFAULT   LOG_OUTPUT_TEXT
 Default log format output type (TEXT = human-readable, JSON = structured).
#define OPT_LOG_FORMAT_CONSOLE_DEFAULT   false
 Default log format console only flag (false = use default format everywhere).
#define OPT_WIDTH_DEFAULT   110
 Default terminal width in characters.
#define OPT_HEIGHT_DEFAULT   70
 Default terminal height in characters.
#define OPT_AUTO_WIDTH_DEFAULT   true
 Default auto-detect width flag (true = auto-detect from terminal).
#define OPT_AUTO_HEIGHT_DEFAULT   true
 Default auto-detect height flag (true = auto-detect from terminal).
#define OPT_COLOR_MODE_DEFAULT   COLOR_MODE_AUTO
 Default color mode (auto-detect terminal capabilities).
#define OPT_LIST_WEBCAMS_DEFAULT   false
 Default list webcams flag (false = don't list and exit).
#define OPT_LIST_MICROPHONES_DEFAULT   false
 Default list microphones flag (false = don't list and exit).
#define OPT_LIST_SPEAKERS_DEFAULT   false
 Default list speakers flag (false = don't list and exit).
#define OPT_SHOW_CAPABILITIES_DEFAULT   false
 Default show terminal capabilities flag.
#define OPT_FORCE_UTF8_DEFAULT   UTF8_SETTING_AUTO
 Default force UTF-8 support setting (auto-detect).
#define OPT_STRIP_ANSI_DEFAULT   false
 Default strip ANSI escape sequences flag.
#define OPT_COLOR_DEFAULT   COLOR_SETTING_AUTO
 Default color setting (COLOR_SETTING_AUTO = smart detection).
#define OPT_COLOR_FILTER_DEFAULT   COLOR_FILTER_NONE
 Default color filter (none - no filtering).
#define OPT_RENDER_MODE_DEFAULT   RENDER_MODE_FOREGROUND
 Default render mode (foreground characters only).
#define OPT_PALETTE_TYPE_DEFAULT   PALETTE_STANDARD
 Default palette type (standard ASCII art).
#define OPT_PALETTE_CUSTOM_SET_DEFAULT   false
 Default custom palette set flag (false = not set).
#define OPT_STRETCH_DEFAULT   false
 Default allow aspect ratio distortion flag.
#define OPT_FPS_DEFAULT   0
 Default FPS (frames per second).
#define OPT_SNAPSHOT_MODE_DEFAULT   false
 Default snapshot mode flag (false = continuous).
#define OPT_SNAPSHOT_DELAY_DEFAULT   3.0f
 Default snapshot delay in seconds.
#define OPT_MATRIX_RAIN_DEFAULT   false
 Default Matrix rain effect flag (false = disabled).
#define OPT_FPS_COUNTER_DEFAULT   false
 Default FPS counter overlay flag (false = disabled).
#define OPT_FLIP_X_DEFAULT   true
 Webcam input is mirrored unless an orientation is explicitly selected.
#define OPT_FLIP_Y_DEFAULT   false
 Default vertical flip state (false = no vertical flip).
#define OPT_WEBCAM_INDEX_DEFAULT   0
 Default webcam device index.
#define OPT_TEST_PATTERN_DEFAULT   false
 Default test pattern mode (false = use actual webcam).
#define OPT_NO_AUDIO_MIXER_DEFAULT   false
 Default no audio mixer flag (false = enable mixer).
#define OPT_MEDIA_LOOP_DEFAULT   false
 Default loop media flag (false = play once).
#define OPT_MEDIA_FROM_STDIN_DEFAULT   false
 Default media from stdin flag (false = not reading from stdin).
#define OPT_MEDIA_SEEK_TIMESTAMP_DEFAULT   0.0
 Default media seek timestamp (start from beginning).
#define OPT_PAUSE_DEFAULT   false
 Default pause media flag (false = play immediately).
#define OPT_ADDRESS_DEFAULT   "localhost"
 Default server address for client connections.
#define OPT_ADDRESS6_DEFAULT   "::1"
 Default IPv6 server address.
#define OPT_ENDPOINT_DISCOVERY_SERVICE   "localhost"
 Default discovery service endpoint (what to connect to by default).
#define OPT_PORT_DEFAULT   "27224"
 Default TCP port for client/server communication (string).
#define OPT_PORT_INT_DEFAULT   27224
 Default TCP port for client/server communication (integer).
#define OPT_WEBSOCKET_PORT_SERVER_DEFAULT   27226
 Default WebSocket port for server mode (integer).
#define OPT_WEBSOCKET_PORT_ACDS_DEFAULT   27227
 Default WebSocket port for discovery-service mode (integer).
#define OPT_MCP_PORT_DEFAULT   27228
#define OPT_MAX_CLIENTS_DEFAULT   9
 Default maximum concurrent clients (server only).
#define OPT_RECONNECT_ATTEMPTS_DEFAULT   (-1)
 Default reconnect attempts (-1 means auto/infinite).
#define OPT_COMPRESSION_LEVEL_DEFAULT   3
 Default compression level (1-9).
#define OPT_NO_COMPRESS_DEFAULT   false
 Default no compression flag (false = enable compression).
#define OPT_ACDS_DEFAULT   false
 Default ACDS registration flag (false = disabled).
#define OPT_ACDS_PORT_INT_DEFAULT   27225
 Default ACDS discovery service port (integer).
#define OPT_ACDS_PORT_DEFAULT   "27225"
 Default ACDS discovery service port (string).
#define OPT_ACDS_EXPOSE_IP_DEFAULT   false
 Default ACDS expose IP flag (false = private by default).
#define OPT_ACDS_INSECURE_DEFAULT   false
 Default ACDS insecure mode flag (false = verify server).
#define OPT_REQUIRE_SERVER_IDENTITY_DEFAULT   false
 Default require-server-identity setting for ACDS.
#define OPT_REQUIRE_CLIENT_IDENTITY_DEFAULT   false
 Default require-client-identity setting for ACDS.
#define OPT_LAN_DISCOVERY_DEFAULT   false
 Default LAN discovery flag (false = discovery disabled).
#define OPT_NO_MDNS_ADVERTISE_DEFAULT   false
 Default no mDNS advertise flag (false = advertise enabled).
#define OPT_ENABLE_UPNP_DEFAULT   false
 Default enable UPnP flag (false = UPnP disabled).
Network Endpoint Defaults (WebRTC)

Centralized definitions for STUN/TURN servers

#define OPT_ENDPOINT_STUN_PRIMARY   "stun:stun.ascii-chat.com:3478"
 Primary STUN server (ascii-chat hosted).
#define OPT_ENDPOINT_STUN_FALLBACK   "stun:stun.l.google.com:19302"
 Fallback STUN server (Google public STUN).
#define OPT_ENDPOINT_STUN_SERVERS_DEFAULT   OPT_ENDPOINT_STUN_PRIMARY "," OPT_ENDPOINT_STUN_FALLBACK
 Default STUN servers (comma-separated list).
#define OPT_ENDPOINT_TURN_PRIMARY   "turn:turn.ascii-chat.com:3478"
 Primary TURN server (ascii-chat hosted).
#define OPT_ENDPOINT_TURN_SERVERS_DEFAULT   OPT_ENDPOINT_TURN_PRIMARY
 Default TURN servers (comma-separated list).
#define OPT_STUN_SERVER_HOST_PRIMARY   "stun.ascii-chat.com"
 STUN server hostname only (without protocol/port).
#define OPT_STUN_SERVER_PORT_PRIMARY   3478
 STUN server port for primary server.
#define OPT_STUN_SERVER_HOST_FALLBACK   "stun.l.google.com"
 Fallback STUN server hostname only.
#define OPT_STUN_SERVER_PORT_FALLBACK   19302
 Fallback STUN server port.
#define OPT_TURN_SERVER_HOST   "turn.ascii-chat.com"
 TURN server hostname only.
#define OPT_TURN_SERVER_PORT   3478
 TURN server port.
#define OPT_STUN_SERVERS_DEFAULT   OPT_ENDPOINT_STUN_SERVERS_DEFAULT
 Default STUN server URLs (comma-separated).
#define OPT_TURN_SERVERS_DEFAULT   OPT_ENDPOINT_TURN_SERVERS_DEFAULT
 Default TURN server URLs (comma-separated).

Typedefs

typedef struct options_state options_t
 Immutable, RCU-published snapshot of the application's runtime configuration.

Enumerations

enum  color_setting_t { COLOR_SETTING_AUTO = 0 , COLOR_SETTING_TRUE = 1 , COLOR_SETTING_FALSE = -1 }
 For options state, this is the live record that ties detected_mode, mode_arg_index, help, version together. The owning code creates it, updates it while work is active, and releases its handles and pointed-to storage before freeing the record. More...
enum  utf8_setting_t { UTF8_SETTING_AUTO = 0 , UTF8_SETTING_TRUE = 1 , UTF8_SETTING_FALSE = -1 }
 UTF-8 support setting (–utf8 flag values). More...
enum  audio_source_t {
  AUDIO_SOURCE_ALL = 0 , AUDIO_SOURCE_CALL = 1 , AUDIO_SOURCE_MIC = 2 , AUDIO_SOURCE_MEDIA = 3 ,
  AUDIO_SOURCE_AUTO = AUDIO_SOURCE_ALL
}
 Audio source selected for visualization. More...
enum  audio_capture_source_t {
  AUDIO_CAPTURE_SOURCE_AUTO = 0 , AUDIO_CAPTURE_SOURCE_MIC = 1 , AUDIO_CAPTURE_SOURCE_MEDIA = 2 , AUDIO_CAPTURE_SOURCE_BOTH = 3 ,
  AUDIO_CAPTURE_SOURCE_REMOTE = 4
}
enum  asciichat_mode_t {
  MODE_SERVER , MODE_CLIENT , MODE_MIRROR , MODE_DISCOVERY_SERVICE ,
  MODE_DISCOVERY , MODE_MCP_SERVER , MODE_API_SERVER , MODE_INVALID
}
 Mode type for options parsing. More...
enum  option_mode_bitmask_t {
  OPTION_MODE_NONE = 0 , OPTION_MODE_SERVER = (1 << MODE_SERVER) , OPTION_MODE_CLIENT = (1 << MODE_CLIENT) , OPTION_MODE_MIRROR = (1 << MODE_MIRROR) ,
  OPTION_MODE_DISCOVERY_SVC = (1 << MODE_DISCOVERY_SERVICE) , OPTION_MODE_DISCOVERY = (1 << MODE_DISCOVERY) , OPTION_MODE_MCP_SERVER = (1 << MODE_MCP_SERVER) , OPTION_MODE_API_SERVER = (1 << MODE_API_SERVER) ,
  OPTION_MODE_BINARY = 0x100 , OPTION_MODE_ALL = 0x7F | 0x100
}
 Option mode bitmask. More...
enum  ascii_renderer_t { ASCII_RENDERER_LUMINANCE = 0 , ASCII_RENDERER_GLYPH = 1 }
 Consolidated options structure. More...

Functions

const options_t * options_get (void)
 Get current options (lock-free read).
const terminal_options_t * options_terminal_settings_ptr (void)
asciichat_error_t options_set_int (const char *field_name, int value)
 Check if an option was explicitly set via command-line.
asciichat_error_t options_set_bool (const char *field_name, bool value)
asciichat_error_t options_set_string (const char *field_name, const char *value)
asciichat_error_t options_set_double (const char *field_name, double value)
const char * options_get_help_text (asciichat_mode_t mode, const char *option_name)
 Get help text for an option in a specific mode.
bool has_action_flag (void)
 Check if an action flag was detected.
void options_resolve_flip_x (options_t *opts)
Utility Functions
int strtoint_safe (const char *str)
 Safely parse string to integer with validation.
Option Parsing Functions
options_t options_t_new (void)
 Initialize options by parsing command-line arguments.
asciichat_error_t options_init (int argc, char **argv)
 Initialize options by parsing command-line arguments with unified mode detection.
void usage (FILE *stream, asciichat_mode_t mode)
 Print usage information for a specific mode.

Variables

const float weight_red
 Red weight for luminance calculation.
const float weight_green
 Green weight for luminance calculation.
const float weight_blue
 Blue weight for luminance calculation.
unsigned short int RED []
 Red channel lookup table.
unsigned short int GREEN []
 Green channel lookup table.
unsigned short int BLUE []
 Blue channel lookup table.
unsigned short int GRAY []
 Grayscale lookup table.

Dimension Update Functions

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
void update_dimensions_to_terminal_size (options_t *opts)
 Update dimensions to match current terminal size.
void update_dimensions_for_full_height (options_t *opts)
 Update dimensions to use full terminal height while maintaining aspect ratio.

Detailed Description

⚙️ Unified options parsing system for ascii-chat with builder pattern and lock-free access

Definition in file options.h.

Function Documentation

◆ options_resolve_flip_x()

void options_resolve_flip_x ( options_t * opts)

Resolve source defaults without turning them into a user selection.

Definition at line 2575 of file options.c.

2575 {
2576 if (!opts->flip_x_explicit)
2577 opts->flip_x = !opts->media_input && !opts->test_pattern && !opts->waveform && !opts->fft;
2578}
bool flip_x_explicit
User selected an orientation for this process lifetime.
Definition options.h:1104
bool fft
Replace the video image with a live audio frequency spectrogram.
Definition options.h:1124
bool media_input
Active input is a file/URL rather than the webcam.
Definition options.h:1105
bool waveform
Replace the video image with a live audio waveform.
Definition options.h:1123
bool test_pattern
Use test pattern instead of webcam.
Definition options.h:1071
bool flip_x
Effective horizontal orientation.
Definition options.h:1103

References options_state::fft, options_state::flip_x, options_state::flip_x_explicit, options_state::media_input, options_state::test_pattern, and options_state::waveform.

Referenced by options_prepare_patch(), and options_state_set().

Variable Documentation

◆ g_snapshot_actual_duration_ms

uint64_t g_snapshot_actual_duration_ms
extern

Definition at line 57 of file src/common/session/render.c.

Referenced by ffmpeg_encoder_write_frame(), and session_render_loop().

◆ g_snapshot_first_capture_ns

uint64_t g_snapshot_first_capture_ns
extern

Definition at line 56 of file src/common/session/render.c.

Referenced by session_render_loop().

◆ g_snapshot_first_frame_rendered

bool g_snapshot_first_frame_rendered
extern

Snapshot mode global timing variables Used to track actual duration when snapshot mode is active.

Definition at line 54 of file src/common/session/render.c.

◆ g_snapshot_first_frame_rendered_ns

uint64_t g_snapshot_first_frame_rendered_ns
extern