MayaFlux 0.2.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
MayaFlux::IO::CameraReader Class Reference

FFmpeg device reader for live camera input with background decode. More...

#include <CameraReader.hpp>

+ Collaboration diagram for MayaFlux::IO::CameraReader:

Public Member Functions

 CameraReader ()
 
 ~CameraReader ()
 
 CameraReader (const CameraReader &)=delete
 
CameraReaderoperator= (const CameraReader &)=delete
 
 CameraReader (CameraReader &&)=delete
 
CameraReaderoperator= (CameraReader &&)=delete
 
bool open (const CameraConfig &config)
 Open a camera device using the supplied config.
 
void close ()
 Release codec, demux, and scratch buffer resources.
 
bool is_open () const
 True if the device is open and codec is ready.
 
std::shared_ptr< Kakshya::CameraContainercreate_container () const
 Create a CameraContainer sized to the negotiated device resolution.
 
bool pull_frame (const std::shared_ptr< Kakshya::CameraContainer > &container)
 Decode one frame from the device into the container's m_data[0].
 
uint32_t width () const
 Negotiated output width in pixels.
 
uint32_t height () const
 Negotiated output height in pixels.
 
double frame_rate () const
 Negotiated frame rate in fps.
 
void set_container (const std::shared_ptr< Kakshya::CameraContainer > &container)
 Store a weak reference to the container for IOService dispatch.
 
void pull_frame_all ()
 Signal the background decode thread to pull one frame.
 
const std::string & last_error () const
 Last error string, empty if no error.
 
void setup_io_service (uint64_t reader_id)
 Setup an IOService for this reader with the given reader_id.
 

Private Member Functions

void start_decode_thread ()
 
void stop_decode_thread ()
 
void decode_thread_func ()
 

Private Attributes

std::shared_ptr< FFmpegDemuxContextm_demux
 
std::shared_ptr< VideoStreamContextm_video
 
std::shared_mutex m_ctx_mutex
 
std::vector< uint8_t > m_sws_buf
 
std::string m_last_error
 
std::weak_ptr< Kakshya::CameraContainerm_container_ref
 
std::shared_ptr< Registry::Service::IOServicem_standalone_service
 
uint64_t m_standalone_reader_id {}
 
bool m_owns_service {}
 
bool m_scaler_ready {}
 
std::thread m_decode_thread
 
std::mutex m_decode_mutex
 
std::condition_variable m_decode_cv
 
std::atomic< bool > m_decode_stop { false }
 
std::atomic< bool > m_decode_active { false }
 
std::atomic< bool > m_frame_requested { false }
 

Detailed Description

FFmpeg device reader for live camera input with background decode.

Owns the FFmpeg demux and video codec contexts for a single camera device. Decodes frames on a dedicated thread signalled by IOService::request_frame, writing RGBA pixels directly into CameraContainer::mutable_frame_ptr() and marking the container READY. The graphics thread is never blocked by device I/O.

Two integration paths:

Unlike VideoFileReader there is no ring buffer, no seek, and no batch decode — the device is a live unbounded source. One frame is pulled per process cycle, demand-driven by CameraContainer::process_default().

Definition at line 71 of file CameraReader.hpp.


The documentation for this class was generated from the following files: