ascii-chat
Binary v0.15.83-53-gb711d8720
Library lib/v0.3.2-701-gb711d8720
Video chat in your terminal
Loading...
Searching...
No Matches
renderer.h
Go to the documentation of this file.
1
9#pragma once
10
11#include <stdint.h>
12#include <stddef.h>
14#include <libplatform/filesystem.h>
15
16// ── Platform renderer ─────────────────────────────────────────────────────
17
19
32
33typedef struct {
34 int cols;
35 int rows;
36 double font_size_pt; // point size, default 12.0 (fractional sizes supported)
38 char font_spec[PLATFORM_MAX_PATH_LENGTH]; // resolved by platform_font_resolve()
39 bool font_is_path; // true = file path, false = name or bundled data
40 const uint8_t *font_data; // non-NULL → load from memory
46
47// Implemented in lib/media/render/terminal.c using FreeType on all platforms.
51
52asciichat_error_t term_renderer_feed(terminal_renderer_t *r, const char *ansi_frame, size_t len);
60
61// ── Render-file orchestrator ──────────────────────────────────────────────
62
64
65// Create: allocates renderer + FFmpeg encoder.
66// cols/rows from terminal size; fps/theme from GET_OPTION().
67asciichat_error_t render_file_create(const char *output_path, int cols, int rows, int fps, int theme,
69
70// Feed one ANSI frame string — renders pixels then writes to encoder, synced with audio.
71// captured_ns is the wall-clock timestamp (in nanoseconds) when the frame was captured
72// for proper frame timing in the output video.
73asciichat_error_t render_file_write_frame(render_file_ctx_t *ctx, const char *ansi_frame, uint64_t captured_ns);
74
75/* Live sessions use capture timestamps; file conversion retains constant-frame-rate timing. */
77
78// Set actual wall-clock duration for snapshot mode (passes through to encoder).
79void render_file_set_snapshot_actual_duration(render_file_ctx_t *ctx, double actual_duration_sec);
80
81// Show terminal progress while accepted frames drain. Safe alongside frame writes.
82void render_file_begin_drain(render_file_ctx_t *ctx, uint64_t total, bool total_known);
83
84// Flush encoder and close file. Always frees *ctx regardless of error.
Synchronized per-thread pending error stacks and value snapshots. SET_ERRNO pushes,...
#define PLATFORM_MAX_PATH_LENGTH
Definition common.h:95
unsigned long long uint64_t
Definition common.h:63
unsigned char uint8_t
Definition common.h:60
asciichat_error_t
Error and exit codes - unified status values (0-255).
Definition error_codes.h:44
static bool size_t gotel_query_t * out
Definition queries.h:8
void render_file_set_snapshot_actual_duration(render_file_ctx_t *ctx, double actual_duration_sec)
Definition renderer.c:369
int term_renderer_get_rows(terminal_renderer_t *r)
int term_renderer_get_cols(terminal_renderer_t *r)
int term_renderer_width_px(terminal_renderer_t *r)
struct terminal_renderer_s terminal_renderer_t
Definition renderer.h:18
asciichat_error_t render_file_write_frame(render_file_ctx_t *ctx, const char *ansi_frame, uint64_t captured_ns)
Definition renderer.c:348
void render_file_set_live_timing(render_file_ctx_t *ctx)
Definition renderer.c:266
term_renderer_theme_t
Terminal rendering theme.
Definition renderer.h:27
@ TERM_RENDERER_THEME_LIGHT
Definition renderer.h:29
@ TERM_RENDERER_THEME_DARK
Definition renderer.h:28
@ TERM_RENDERER_THEME_AUTO
Definition renderer.h:30
asciichat_error_t render_file_create(const char *output_path, int cols, int rows, int fps, int theme, render_file_ctx_t **out)
Definition renderer.c:53
const uint8_t * term_renderer_pixels(terminal_renderer_t *r)
asciichat_error_t term_renderer_create(const term_renderer_config_t *cfg, terminal_renderer_t **out)
void term_renderer_destroy(terminal_renderer_t *r)
struct render_file_ctx_s render_file_ctx_t
Definition renderer.h:63
asciichat_error_t render_file_destroy(render_file_ctx_t *ctx)
Definition renderer.c:375
asciichat_error_t term_renderer_set_zalgo(terminal_renderer_t *r, int level)
asciichat_error_t term_renderer_feed(terminal_renderer_t *r, const char *ansi_frame, size_t len)
void render_file_begin_drain(render_file_ctx_t *ctx, uint64_t total, bool total_known)
Definition renderer.c:364
int term_renderer_pitch(terminal_renderer_t *r)
int term_renderer_height_px(terminal_renderer_t *r)
For render file ctx, this is the live record that ties progress, error, renderer, encoder together....
Definition renderer.c:32
const uint8_t * font_data
Definition renderer.h:40
term_renderer_theme_t theme
Definition renderer.h:37
char font_spec[PLATFORM_MAX_PATH_LENGTH]
Definition renderer.h:38