MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ open_camera()

std::shared_ptr< Kakshya::CameraContainer > MayaFlux::IO::IOManager::open_camera ( const CameraConfig &  config)

Open an FFmpeg camera device and create a CameraContainer.

Convenience wrapper over the backend-agnostic hosting path: constructs an FFmpegCameraReader, opens the device, creates the container, configures its FrameAccessProcessor (auto_advance disabled), then calls register_camera_source() to assign a reader_id and wire the container's IOService callback via CameraContainer::setup_io().

A non-FFmpeg backend does not go through this call at all — it opens itself however its own backend requires, then calls register_camera_source() directly with the resulting CameraSource.

After this call, the normal processing pipeline drives frame pulls: CameraContainer::process_default() → IOService::request_frame(reader_id) → dispatch_frame_request() → CameraSource::pull_frame_all() → decode thread → pull_frame() → mutable_frame_ptr() write → READY.

Parameters
configDevice and resolution configuration.
Returns
Opened CameraContainer, or nullptr on failure.

Definition at line 719 of file IOManager.cpp.

720{
721 static std::once_flag s_avdevice_init;
722 std::call_once(s_avdevice_init, [] { avdevice_register_all(); });
723
724 auto reader = std::make_shared<FFmpegCameraReader>();
725
726 if (!reader->open(config)) {
728 "open_camera: failed — {}", reader->last_error());
729 return nullptr;
730 }
731
732 auto container = reader->create_container();
733 if (!container) {
735 "open_camera: failed to create container — {}",
736 reader->last_error());
737 return nullptr;
738 }
739
740 container->create_default_processor();
741 reader->set_container(container);
742
743 const uint64_t rid = register_camera_source(reader);
745
747 "open_camera: reader_id={} device='{}' {}x{} @{:.1f}fps",
748 rid, config.device_name,
749 reader->width(), reader->height(), reader->frame_rate());
750
751 return container;
752}
#define MF_INFO(comp, ctx,...)
#define MF_ERROR(comp, ctx,...)
uint64_t register_camera_source(std::shared_ptr< CameraSource > source)
Assign a globally unique reader_id and take ownership of a CameraSource that is already open.
void configure_camera_container(const std::shared_ptr< Kakshya::CameraContainer > &container, uint64_t reader_id)
@ FileIO
Filesystem I/O operations.
@ API
MayaFlux/API Wrapper and convenience functions.

References MayaFlux::Journal::API, MayaFlux::IO::Detail::configure_camera_container(), MayaFlux::IO::CameraConfig::device_name, MayaFlux::Journal::FileIO, MF_ERROR, MF_INFO, and register_camera_source().

+ Here is the call graph for this function: