ascii-chat 0.6.0
Real-time terminal-based video chat with ASCII art conversion
Loading...
Searching...
No Matches
video_frame_buffer_t Struct Reference

Video frame buffer manager. More...

#include <lib/video/video_frame.h>

Data Fields

Double Buffering
video_frame_tfront_buffer
 Currently displayed frame (reader owns)
 
video_frame_tback_buffer
 Currently written frame (writer owns)
 
Synchronization
atomic_bool 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_ullong total_frames_received
 Total frames received (atomic counter)
 
atomic_ullong total_frames_dropped
 Total frames dropped (atomic counter)
 
atomic_ullong last_frame_sequence
 Last frame sequence number (atomic)
 
Quality Metrics
atomic_uint avg_decode_time_us
 Average decode time in microseconds (atomic)
 
atomic_uint avg_render_time_us
 Average render time in microseconds (atomic)
 
Client Info
uint32_t client_id
 Client ID 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

Video frame buffer manager.

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.

Definition at line 176 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 222 of file video_frame.h.

Referenced by client_video_render_thread(), video_frame_buffer_create(), and video_frame_buffer_destroy().

◆ avg_decode_time_us

atomic_uint video_frame_buffer_t::avg_decode_time_us

Average decode time in microseconds (atomic)

Definition at line 208 of file video_frame.h.

Referenced by video_frame_get_stats().

◆ avg_render_time_us

atomic_uint video_frame_buffer_t::avg_render_time_us

Average render time in microseconds (atomic)

Definition at line 209 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 181 of file video_frame.h.

Referenced by video_frame_begin_write(), video_frame_buffer_create(), and video_frame_commit().

◆ client_id

uint32_t video_frame_buffer_t::client_id

Client ID this buffer belongs to.

Definition at line 215 of file video_frame.h.

Referenced by video_frame_buffer_create(), and video_frame_commit().

◆ frames

video_frame_t video_frame_buffer_t::frames[2]

Pre-allocated frame structures (reused forever)

Definition at line 194 of file video_frame.h.

Referenced by video_frame_buffer_create(), and video_frame_buffer_destroy().

◆ front_buffer

video_frame_t* video_frame_buffer_t::front_buffer

Currently displayed frame (reader owns)

Definition at line 180 of file video_frame.h.

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

◆ last_frame_sequence

atomic_ullong video_frame_buffer_t::last_frame_sequence

Last frame sequence number (atomic)

Definition at line 202 of file video_frame.h.

Referenced by video_frame_buffer_create().

◆ new_frame_available

atomic_bool video_frame_buffer_t::new_frame_available

Atomic flag: true when new frame available.

Definition at line 187 of file video_frame.h.

Referenced by video_frame_buffer_create(), 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 188 of file video_frame.h.

Referenced by video_frame_buffer_create(), and video_frame_buffer_destroy().

◆ total_frames_dropped

atomic_ullong video_frame_buffer_t::total_frames_dropped

Total frames dropped (atomic counter)

Definition at line 201 of file video_frame.h.

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

◆ total_frames_received

atomic_ullong video_frame_buffer_t::total_frames_received

Total frames received (atomic counter)

Definition at line 200 of file video_frame.h.

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


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