ascii-chat 0.11.33
Video chat in your terminal
Loading...
Searching...
No Matches
media.c
Go to the documentation of this file.
1
15
18
19// ============================================================================
20// Validators
21// ============================================================================
22
23static bool validate_render_font_size(const void *opts_struct, char **error_msg) {
24 (void)opts_struct;
25 const options_t *opts = (const options_t *)opts_struct;
26 if (opts->render_font_size <= 0.0) {
27 if (error_msg)
28 *error_msg = platform_strdup("--render-font-size must be > 0");
29 return false;
30 }
31 return true;
32}
33
34// ============================================================================
35// MEDIA CATEGORY - Media file and stream options
36// ============================================================================
38 // Media File Streaming Options
39 {"file",
40 'f',
42 offsetof(options_t, media_file),
43 "",
44 0,
45 "Stream from media file or stdin (use '-' for stdin). Supported formats: see man ffmpeg-formats; codecs: see man "
46 "ffmpeg-codecs.",
47 "MEDIA",
48 NULL,
49 false,
50 "ASCII_CHAT_FILE",
51 NULL,
52 NULL,
53 false,
54 false,
56 {0},
57 NULL},
58 {"url",
59 'u',
61 offsetof(options_t, media_url),
62 "",
63 0,
64 "Stream from network URL. Direct HTTP/HTTPS/RTSP streams use FFmpeg; complex sites (YouTube, TikTok, etc.) use "
65 "yt-dlp. Supported formats: see man ffmpeg-formats; codecs: see man ffmpeg-codecs; sites: yt-dlp "
66 "https://github.com/yt-dlp/yt-dlp/blob/master/README.md#supported-sites.",
67 "MEDIA",
68 NULL,
69 false,
70 "ASCII_CHAT_URL",
71 NULL,
72 NULL,
73 false,
74 false,
76 {0},
77 NULL},
78 {"loop",
79 'l',
81 offsetof(options_t, media_loop),
82 &default_media_loop_value,
83 sizeof(bool),
84 "Loop media file playback (not supported for --url).",
85 "MEDIA",
86 NULL,
87 false,
88 "ASCII_CHAT_LOOP",
89 NULL,
90 NULL,
91 false,
92 false,
94 {0},
95 NULL},
96 {"pause",
97 '\0',
99 offsetof(options_t, pause),
100 &default_pause_value,
101 sizeof(bool),
102 "Start playback paused (toggle with spacebar, requires --file or --url).",
103 "MEDIA",
104 NULL,
105 false,
106 "ASCII_CHAT_PAUSE",
107 NULL,
108 NULL,
109 false,
110 false,
112 {0},
113 NULL},
114 {"seek",
115 's',
117 offsetof(options_t, media_seek_timestamp),
118 &default_media_seek_value,
119 sizeof(double),
120 "Seek to timestamp before playback (format: seconds, MM:SS, or HH:MM:SS.ms).",
121 "MEDIA",
122 NULL,
123 false,
124 "ASCII_CHAT_SEEK",
125 NULL,
127 false,
128 false,
130 {.examples = g_seek_examples, .input_type = OPTION_INPUT_STRING},
131 NULL},
132 {"yt-dlp-options",
133 '\0',
135 offsetof(options_t, yt_dlp_options),
136 NULL,
137 sizeof(((options_t *)0)->yt_dlp_options),
138 "Arbitrary yt-dlp options passed to the extraction subprocess for URL resolution. "
139 "Examples: --no-warnings or --proxy socks5://127.0.0.1:1080 or --cookies-from-browser=firefox.",
140 "MEDIA",
141 NULL,
142 false,
143 "ASCII_CHAT_YT_DLP_OPTIONS",
144 NULL,
145 NULL,
146 false,
147 false,
149 {0},
150 NULL},
151 {"video-codec",
152 '\0',
154 offsetof(options_t, video_codec),
155 "hevc",
156 sizeof(((options_t *)0)->video_codec),
157 "Video codec for streaming (raw, hevc). raw=uncompressed RGB, hevc=H.265 compression. Default: hevc.",
158 "MEDIA",
159 "CODEC",
160 false,
161 "ASCII_CHAT_VIDEO_CODEC",
162 NULL,
163 NULL,
164 false,
165 false,
167 {0},
168 NULL},
169
170#define RENDER_FILE_MODES (OPTION_MODE_CLIENT | OPTION_MODE_MIRROR | OPTION_MODE_DISCOVERY)
171
172 {"render-file",
173 '\0',
175 offsetof(options_t, render_file),
176 "",
177 sizeof(((options_t *)0)->render_file),
178 "Render ASCII frames to stdout or video/image file. Use '-' for stdout; extension determines format: "
179 ".mp4, .mov, .webm, .avi, .gif, .png, .jpg.",
180 "MEDIA",
181 "PATH",
182 false,
183 "ASCII_CHAT_RENDER_FILE",
184 NULL,
185 NULL,
186 false,
187 false,
189 {0},
190 NULL},
191
192 {"render-theme",
193 '\0',
195 offsetof(options_t, render_theme),
196 &default_render_theme_value,
197 sizeof(int),
198 "Terminal color scheme for rendered output: dark, light, auto.",
199 "MEDIA",
200 "THEME",
201 false,
202 "ASCII_CHAT_RENDER_THEME",
203 NULL,
205 false,
206 false,
208 {.enum_values = g_render_theme_values, .enum_descriptions = g_render_theme_descs, .input_type = OPTION_INPUT_ENUM},
209 NULL},
210
211 {"render-font",
212 '\0',
214 offsetof(options_t, render_font),
215 "",
216 sizeof(((options_t *)0)->render_font),
217 "Font for render-file output: bundled names (matrix or default), system font names, or absolute .ttf/.otf path. "
218 "Default: default (bundled DejaVu Sans Mono). "
219 "Examples: matrix, default, JetBrains Mono, Nerd Font Mono, /path/to/font.ttf.",
220 "MEDIA",
221 "FONT",
222 false,
223 "ASCII_CHAT_RENDER_FONT",
224 NULL,
225 NULL,
226 false,
227 false,
229 {0},
230 NULL},
231
232 {"render-font-size",
233 '\0',
235 offsetof(options_t, render_font_size),
236 &default_render_font_size_value,
237 sizeof(double),
238 "Font size in points for render-file output (default: 12.0, must be > 0, fractional sizes supported e.g. 10.5).",
239 "MEDIA",
240 "SIZE",
241 false,
242 "ASCII_CHAT_RENDER_FONT_SIZE",
243 validate_render_font_size,
244 NULL,
245 false,
246 false,
248 {.input_type = OPTION_INPUT_NUMERIC},
249 NULL},
250
@ OPTION_INPUT_STRING
Free-form text input.
Definition builder.h:180
@ OPTION_INPUT_NUMERIC
Numeric value with optional min/max/step.
Definition builder.h:179
@ OPTION_INPUT_ENUM
Choose from fixed set of enum values.
Definition builder.h:178
@ OPTION_TYPE_DOUBLE
Floating point (–ratio 1.5)
Definition builder.h:165
@ OPTION_TYPE_STRING
String value (–name foo)
Definition builder.h:164
@ OPTION_TYPE_CALLBACK
Custom parser function.
Definition builder.h:166
@ OPTION_TYPE_BOOL
Boolean flag (–flag, no value)
Definition builder.h:162
@ OPTION_MODE_CLIENT
Client mode (bit 1)
@ OPTION_MODE_DISCOVERY
Discovery mode (bit 4)
@ OPTION_MODE_MIRROR
Mirror mode (bit 2)
char * platform_strdup(const char *s)
Duplicate string (strdup replacement)
const registry_entry_t g_media_entries[]
Definition media.c:37
#define RENDER_FILE_MODES
const char * g_render_theme_values[]
Definition metadata.c:145
const char * g_seek_examples[]
Definition metadata.c:189
const char * g_render_theme_descs[]
Definition metadata.c:147
Extern declarations for shared metadata arrays.
Shared structures and macros for registry implementation.
#define REGISTRY_TERMINATOR()
Initialize a terminator entry (sentinel value for array end) Uses designated initializers to properly...
bool parse_timestamp(const char *arg, void *dest, char **error_msg)
Custom parser for –seek flag.
Definition parsers.c:1010
bool parse_render_theme(const char *arg, void *dest, char **error_msg)
Parse render theme option for pixel rendering.
Definition parsers.c:346
Custom option parsers for enum types.
Cross-platform memory allocation utilities.
#define bool
Definition stdbool.h:61
Consolidated options structure.
double render_font_size
Font size in points (default 12.0, supports e.g. 10.5)
Registry entry - stores option definition with mode bitmask and metadata.