ascii-chat
Binary v0.16.114-28-gf5913657f
Library lib/v0.3.2-3302-gf5913657f
Video chat in your terminal
Loading...
Searching...
No Matches
ffmpeg_decoder.h
Go to the documentation of this file.
1#pragma once
2
40
41#include "../common.h"
44#include <stdbool.h>
45#include <stddef.h>
46
47#ifdef __cplusplus
48extern "C" {
49#endif
50
51/* ============================================================================
52 * FFmpeg Decoder Handle
53 * ============================================================================
54 */
55
65
66/* ============================================================================
67 * Decoder Lifecycle
68 * ============================================================================
69 */
70
92
117
137
158
169
189 bool (*should_exit_callback)(void *),
190 void *user_data);
191
203
204/* ============================================================================
205 * Video Operations
206 * ============================================================================
207 */
208
244
250
259
270 int *width, int *height);
271
282
283/* ============================================================================
284 * Audio Operations
285 * ============================================================================
286 */
287
318 float *buffer, size_t num_samples);
319
328
329/* ============================================================================
330 * Playback Control
331 * ============================================================================
332 */
333
352
374 double timestamp_sec);
375
384
395
406
408
410 bool (*cancel)(void *),
411 void *data);
413 const char *path, bool (*cancel)(void *), void *data, const char *headers,
414 const char *cookies, const char *proxy);
415
416#ifdef __cplusplus
417}
418#endif
Synchronized per-thread pending error stacks and value snapshots. SET_ERRNO pushes,...
ffmpeg_decoder_t * ffmpeg_decoder_create_interruptible(const char *path, bool(*cancel)(void *), void *data)
ffmpeg_decoder_t * ffmpeg_decoder_create_with_request_options(const char *path, bool(*cancel)(void *), void *data, const char *headers, const char *cookies, const char *proxy)
unsigned int height
Definition fft.c:24
unsigned int width
Definition fft.c:24
asciichat_error_t
Error and exit codes - unified status values (0-255).
Definition error_codes.h:48
bool ffmpeg_decoder_at_end(ffmpeg_decoder_t *decoder)
Check if decoder reached end of stream.
double ffmpeg_decoder_get_position(ffmpeg_decoder_t *decoder)
Get current playback position in seconds.
void ffmpeg_decoder_stop_prefetch(ffmpeg_decoder_t *decoder)
Stop background frame prefetching thread.
image_t * ffmpeg_decoder_read_video_frame(ffmpeg_decoder_t *decoder)
bool ffmpeg_decoder_has_video(ffmpeg_decoder_t *decoder)
Check if decoder has video stream.
double ffmpeg_decoder_get_video_fps(ffmpeg_decoder_t *decoder)
Get video frame rate.
asciichat_error_t ffmpeg_decoder_rewind(ffmpeg_decoder_t *decoder)
Seek to beginning of media.
asciichat_error_t ffmpeg_decoder_get_video_dimensions(ffmpeg_decoder_t *decoder, int *width, int *height)
Get video dimensions.
ffmpeg_frame_status_t
Decode next video frame.
bool ffmpeg_decoder_has_audio(ffmpeg_decoder_t *decoder)
Check if decoder has audio stream.
bool ffmpeg_decoder_is_prefetch_running(ffmpeg_decoder_t *decoder)
Check if background frame prefetching thread is running.
asciichat_error_t ffmpeg_decoder_start_prefetch(ffmpeg_decoder_t *decoder)
Start background frame prefetching thread.
asciichat_error_t ffmpeg_decoder_seek_to_timestamp(ffmpeg_decoder_t *decoder, double timestamp_sec)
Seek to specific timestamp in media.
void ffmpeg_decoder_set_exit_callback(ffmpeg_decoder_t *decoder, bool(*should_exit_callback)(void *), void *user_data)
Set exit signal callback for graceful shutdown during I/O.
void ffmpeg_decoder_destroy(ffmpeg_decoder_t *decoder)
Destroy FFmpeg decoder and free resources.
ffmpeg_decoder_t * ffmpeg_decoder_create(const char *path)
Create FFmpeg decoder from file path.
size_t ffmpeg_decoder_read_audio_samples(ffmpeg_decoder_t *decoder, float *buffer, size_t num_samples)
Decode audio samples.
ffmpeg_frame_status_t ffmpeg_decoder_poll_video(ffmpeg_decoder_t *decoder, image_t **frame, asciichat_error_context_t *failure)
ffmpeg_decoder_t * ffmpeg_decoder_create_stdin(void)
Create FFmpeg decoder from stdin.
double ffmpeg_decoder_get_duration(ffmpeg_decoder_t *decoder)
Get media duration in seconds.
@ FFMPEG_FRAME_READY
@ FFMPEG_FRAME_WAITING
@ FFMPEG_FRAME_FAILED
@ FFMPEG_FRAME_EOF
⚙️ Common definitions, error codes, macros, and types shared throughout the application
FFmpeg decoder state for video and audio decoding.
atomic_ptr_t should_exit_callback
Callback to check if app should exit.
AVFrame * frame
Reusable frame for decoding.