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

◆ capture_spatial()

uint32_t MayaFlux::IO::IOManager::capture_spatial ( const std::string & filepath,
std::vector< IO::SpatialCaptureSource > sources,
uint32_t max_frames = 0,
uint64_t frame_interval = 1 )
nodiscard

Begin (or join) recording time-sampled streams into an Alembic archive.

Resolves filepath to a shared SpatialCache: the first call for a given path opens it, and a later call passing the same path reuses the cache already open, so several independent captures can each record their own streams into one archive. Unlike capture_volume, nothing is numbered per frame: Alembic carries time natively, so every sample of every stream lands in the one file across the whole recording.

Spawns a SpatialCapture on the engine scheduler and retains it, the same GraphicsRoutine/FrameDelay shape capture_volume uses. For a capture the caller owns and drives itself, construct IO::SpatialCapture directly against a SpatialCache of its own.

Parameters
filepathDestination .abc path.
sourcesStreams to tick together every frame. Build one with IO::make_network_geometry_source() or a hand-written IO::SpatialCaptureSource.
max_framesStop after this many frames. Zero is unbounded.
frame_intervalFrames between captures.
Returns
Capture handle for stop_spatial_capture, or 0 on failure (no sources, no scheduler, or the archive failed to open).

Definition at line 1532 of file IOManager.cpp.

1537{
1538 if (sources.empty()) {
1540 "capture_spatial: no sources");
1541 return 0;
1542 }
1543
1544 if (!m_scheduler) {
1546 "capture_spatial: TaskScheduler unavailable");
1547 return 0;
1548 }
1549
1550 std::shared_ptr<IO::SpatialCache> cache;
1551 {
1552 std::lock_guard lock(m_spatial_captures_mutex);
1553 auto it = m_spatial_caches.find(filepath);
1554 if (it != m_spatial_caches.end()) {
1555 cache = it->second;
1556 } else {
1557 auto new_cache = std::make_shared<IO::SpatialCache>();
1558 if (!new_cache->open(filepath)) {
1560 "capture_spatial: failed to open '{}': {}", filepath, new_cache->get_last_error());
1561 return 0;
1562 }
1563 cache = new_cache;
1564 m_spatial_caches.emplace(filepath, cache);
1565 }
1566 ++m_spatial_cache_refcounts[filepath];
1567 }
1568
1569 auto capture = Detail::create_spatial_capture(*m_scheduler, cache, std::move(sources), max_frames, frame_interval);
1570
1571 const uint32_t id = m_next_spatial_capture_id.fetch_add(1, std::memory_order_relaxed);
1572
1573 std::lock_guard lock(m_spatial_captures_mutex);
1574 m_spatial_captures.emplace(id, SpatialCaptureEntry { .capture = std::move(capture), .filepath = filepath });
1575 return id;
1576}
#define MF_ERROR(comp, ctx,...)
std::unordered_map< uint32_t, SpatialCaptureEntry > m_spatial_captures
std::unordered_map< std::string, int > m_spatial_cache_refcounts
Closes+erases a cache at zero.
std::atomic< uint32_t > m_next_spatial_capture_id
std::mutex m_spatial_captures_mutex
std::unordered_map< std::string, std::shared_ptr< IO::SpatialCache > > m_spatial_caches
std::shared_ptr< Vruta::TaskScheduler > m_scheduler
std::unique_ptr< SpatialCapture > create_spatial_capture(Vruta::TaskScheduler &scheduler, const std::shared_ptr< SpatialCache > &cache, std::vector< SpatialCaptureSource > sources, uint32_t max_frames, uint64_t frame_interval)
@ FileIO
Filesystem I/O operations.
@ IO
Networking, file handling, streaming.

References MayaFlux::IO::Detail::create_spatial_capture(), MayaFlux::Journal::FileIO, MayaFlux::Journal::IO, m_next_spatial_capture_id, m_scheduler, m_spatial_cache_refcounts, m_spatial_caches, m_spatial_captures, m_spatial_captures_mutex, and MF_ERROR.

Here is the call graph for this function: