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

Optional orchestration layer for IO reader lifetime and IOService dispatch. More...

#include <IOManager.hpp>

+ Collaboration diagram for MayaFlux::IO::IOManager:

Public Member Functions

 IOManager (uint64_t sample_rate, uint32_t buffer_size, uint32_t frame_rate, const std::shared_ptr< Buffers::BufferManager > &buffer_manager)
 Construct IOManager and register the IOService into BackendRegistry.
 
 ~IOManager ()
 Unregisters IOService, releases all owned readers, clears stored buffers.
 
 IOManager (const IOManager &)=delete
 
IOManageroperator= (const IOManager &)=delete
 
 IOManager (IOManager &&)=delete
 
IOManageroperator= (IOManager &&)=delete
 
std::shared_ptr< Kakshya::VideoFileContainerload_video (const std::string &filepath)
 Load a video file into a VideoFileContainer.
 
VideoLoadResult load_video (const std::string &filepath, LoadConfig config)
 Load a video file into a VideoFileContainer.
 
std::shared_ptr< Buffers::VideoContainerBufferhook_video_container_to_buffer (const std::shared_ptr< Kakshya::VideoFileContainer > &container)
 Wire a VideoFileContainer to the graphics buffer system.
 
std::shared_ptr< Buffers::VideoContainerBufferget_video_buffer (const std::shared_ptr< Kakshya::VideoFileContainer > &container) const
 Retrieve the VideoContainerBuffer created for a container.
 
std::shared_ptr< Kakshya::SoundFileContainerload_audio (const std::string &filepath, LoadConfig config={})
 Load an audio file into a SoundFileContainer.
 
std::vector< std::shared_ptr< Buffers::SoundContainerBuffer > > hook_audio_container_to_buffers (const std::shared_ptr< Kakshya::SoundFileContainer > &container)
 Wire a SoundFileContainer to the audio buffer system.
 
std::vector< std::shared_ptr< Buffers::SoundContainerBuffer > > get_audio_buffers (const std::shared_ptr< Kakshya::SoundFileContainer > &container) const
 Retrieve the SoundContainerBuffers created for a container.
 
std::shared_ptr< Kakshya::SoundFileContainerget_extracted_audio (const std::shared_ptr< Kakshya::VideoFileContainer > &container) const
 Retrieve the SoundFileContainer extracted from a video file.
 
std::shared_ptr< Kakshya::CameraContaineropen_camera (const CameraConfig &config)
 Open a camera device and create a CameraContainer.
 
std::shared_ptr< Buffers::VideoContainerBufferhook_camera_to_buffer (const std::shared_ptr< Kakshya::CameraContainer > &container)
 Wire a CameraContainer to the graphics buffer system.
 
std::shared_ptr< Buffers::VideoContainerBufferget_camera_buffer (const std::shared_ptr< Kakshya::CameraContainer > &container) const
 Retrieve the VideoContainerBuffer created for a camera container.
 
uint64_t register_video_reader (std::shared_ptr< VideoFileReader > reader)
 Assign a globally unique reader_id and take ownership of a reader.
 
void release_video_reader (uint64_t reader_id)
 Release ownership of the reader identified by reader_id.
 
std::shared_ptr< Buffers::TextureBufferload_image (const std::string &filepath)
 Load an image file into a TextureBuffer.
 

Private Member Functions

void dispatch_decode_request (uint64_t reader_id)
 IOService::request_decode target — shared-lock lookup + signal_decode().
 
void dispatch_frame_request (uint64_t reader_id)
 IOService::request_frame target — shared-lock lookup + pull_frame_all().
 
void configure_frame_processor (const std::shared_ptr< Kakshya::VideoFileContainer > &container)
 
void configure_audio_processor (const std::shared_ptr< Kakshya::SoundFileContainer > &container)
 

Private Attributes

uint64_t m_sample_rate
 
uint32_t m_buffer_size
 
uint32_t m_frame_rate
 
std::atomic< uint64_t > m_next_reader_id { 1 }
 
std::shared_mutex m_readers_mutex
 
std::shared_mutex m_camera_mutex
 
std::unordered_map< uint64_t, std::shared_ptr< VideoFileReader > > m_video_readers
 
std::unordered_map< uint64_t, std::shared_ptr< CameraReader > > m_camera_readers
 
std::vector< std::shared_ptr< SoundFileReader > > m_audio_readers
 
std::vector< std::shared_ptr< ImageReader > > m_image_readers
 
std::shared_mutex m_buffers_mutex
 
std::unordered_map< std::shared_ptr< Kakshya::VideoFileContainer >, std::shared_ptr< Buffers::VideoContainerBuffer > > m_video_buffers
 
std::unordered_map< std::shared_ptr< Kakshya::CameraContainer >, std::shared_ptr< Buffers::VideoContainerBuffer > > m_camera_buffers
 
std::unordered_map< std::shared_ptr< Kakshya::VideoFileContainer >, std::shared_ptr< Kakshya::SoundFileContainer > > m_extracted_audio
 
std::unordered_map< std::shared_ptr< Kakshya::SoundFileContainer >, std::vector< std::shared_ptr< Buffers::SoundContainerBuffer > > > m_audio_buffers
 
std::shared_ptr< Buffers::BufferManagerm_buffer_manager
 
std::shared_ptr< Registry::Service::IOServicem_io_service
 

Detailed Description

Optional orchestration layer for IO reader lifetime and IOService dispatch.

MayaFlux IO readers are fully self-sufficient — VideoFileReader, SoundFileReader, and ImageReader can all be used standalone without this class. IOManager exists to solve problems that only arise at scale:

  • Globally unique reader_ids across concurrent VideoFileReader instances, so IOService::request_decode routes to the correct decode thread.
  • A single IOService registration backed by a keyed dispatch map, rather than each reader overwriting the previous registration.
  • Shared ownership of VideoFileReader instances whose background decode thread must outlive the scope in which they were created.
  • High-level load/hook functions that collapse the full open→load→processor setup→buffer wiring sequence into single calls, mirroring what Depot does for audio and eliminating the boilerplate currently required for video.

VideoFileReader detects the IOService registration generically via BackendRegistry and skips its own registration — no IOManager-specific knowledge in the reader.

Levels of integration (all valid):

  1. VideoFileReader standalone, single stream — self-registers, self-ids.
  2. IOManager constructed directly — multi-stream safe, no Engine required.
  3. Engine constructs IOManager in Init() — fully orchestrated, zero user wiring.

Definition at line 75 of file IOManager.hpp.


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