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

One captured, decoded, or rendered video frame and its timing metadata. More...

#include <include/ascii-chat/video/rgba/video_frame.h>

Data Fields

Double Buffering
video_frame_t * front_buffer
 Currently displayed frame (reader owns).
video_frame_t * back_buffer
 Currently written frame (writer owns).
Synchronization
atomic_t new_frame_available
 Atomic flag: true when new frame available.
mutex_t swap_mutex
 Brief mutex for pointer swap only.
Frame Allocation
video_frame_t frames [2]
 Pre-allocated frame structures (reused forever).
Statistics
atomic_t total_frames_received
 Total frames received (atomic counter).
atomic_t total_frames_dropped
 Total frames dropped (atomic counter).
atomic_t last_frame_sequence
 Last frame sequence number (atomic).
Quality Metrics
atomic_t avg_decode_time_ns
 Average decode time in nanoseconds (atomic).
atomic_t avg_render_time_ns
 Average render time in nanoseconds (atomic).
Client Info
const char * client_id
 Client ID (name) this buffer belongs to.
bool active
 True if buffer is active (receiving frames).
Buffer Management
size_t allocated_buffer_size
 Size of allocated data buffers (for cleanup).

Detailed Description

One captured, decoded, or rendered video frame and its timing metadata.

Double-buffered frame storage shared by a producer and a renderer.

Implements double-buffered frame management with atomic pointer swaps for zero-copy frame transfer. Writer thread writes to back buffer while reader thread reads from front buffer. Atomic swap makes new frames available without blocking.

DOUBLE BUFFERING ARCHITECTURE:

  • front_buffer: Currently displayed frame (reader owns)
  • back_buffer: Currently written frame (writer owns)
  • Atomic swap: Swaps front/back when writer commits frame

SYNCHRONIZATION:

  • Atomic bool flag signals when new frame is available
  • Brief mutex for pointer swap (minimal contention)
  • Lock-free reads (reader never blocks writer)

STATISTICS TRACKING:

  • Total frames received/dropped
  • Frame drop rate
  • Average decode/render times
  • Quality metrics for adaptive streaming
Note
Pre-allocates buffers at creation time for zero-allocation operation.
Latest-frame-wins semantics (old frames are dropped, not queued).
Thread-safe: Writer and reader can operate concurrently.

Double-buffered frame storage shared by a producer and a renderer

Definition at line 182 of file video_frame.h.

Field Documentation

◆ active

bool video_frame_buffer_t::active

◆ allocated_buffer_size

size_t video_frame_buffer_t::allocated_buffer_size

Size of allocated data buffers (for cleanup).

Definition at line 228 of file video_frame.h.

◆ avg_decode_time_ns

atomic_t video_frame_buffer_t::avg_decode_time_ns

Average decode time in nanoseconds (atomic).

Definition at line 214 of file video_frame.h.

Referenced by video_frame_get_stats().

◆ avg_render_time_ns

atomic_t video_frame_buffer_t::avg_render_time_ns

Average render time in nanoseconds (atomic).

Definition at line 215 of file video_frame.h.

Referenced by video_frame_get_stats().

◆ back_buffer

video_frame_t* video_frame_buffer_t::back_buffer

Currently written frame (writer owns).

Definition at line 187 of file video_frame.h.

Referenced by video_frame_begin_write(), and video_frame_commit().

◆ client_id

const char* video_frame_buffer_t::client_id

Client ID (name) this buffer belongs to.

Definition at line 221 of file video_frame.h.

Referenced by video_frame_buffer_destroy(), and video_frame_commit().

◆ frames

video_frame_t video_frame_buffer_t::frames[2]

Pre-allocated frame structures (reused forever).

Definition at line 200 of file video_frame.h.

Referenced by video_frame_buffer_destroy().

◆ front_buffer

video_frame_t* video_frame_buffer_t::front_buffer

Currently displayed frame (reader owns).

Definition at line 186 of file video_frame.h.

Referenced by video_frame_commit(), video_frame_get_latest(), and video_frame_peek_latest().

◆ last_frame_sequence

atomic_t video_frame_buffer_t::last_frame_sequence

Last frame sequence number (atomic).

Definition at line 208 of file video_frame.h.

Referenced by video_frame_buffer_destroy().

◆ new_frame_available

atomic_t video_frame_buffer_t::new_frame_available

Atomic flag: true when new frame available.

Definition at line 193 of file video_frame.h.

Referenced by video_frame_buffer_destroy(), video_frame_commit(), and video_frame_get_latest().

◆ swap_mutex

mutex_t video_frame_buffer_t::swap_mutex

Brief mutex for pointer swap only.

Definition at line 194 of file video_frame.h.

Referenced by video_frame_buffer_destroy(), video_frame_commit(), video_frame_get_latest(), and video_frame_peek_latest().

◆ total_frames_dropped

atomic_t video_frame_buffer_t::total_frames_dropped

Total frames dropped (atomic counter).

Definition at line 207 of file video_frame.h.

Referenced by video_frame_buffer_destroy(), video_frame_commit(), and video_frame_get_stats().

◆ total_frames_received

atomic_t video_frame_buffer_t::total_frames_received

Total frames received (atomic counter).

Definition at line 206 of file video_frame.h.

Referenced by video_frame_buffer_destroy(), video_frame_commit(), and video_frame_get_stats().


The documentation for this struct was generated from the following file: