MayaFlux 0.5.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 
)

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 1345 of file IOManager.cpp.

1350{
1351 if (sources.empty()) {
1353 "capture_spatial: no sources");
1354 return 0;
1355 }
1356
1357 if (!m_scheduler) {
1359 "capture_spatial: TaskScheduler unavailable");
1360 return 0;
1361 }
1362
1363 std::shared_ptr<IO::SpatialCache> cache;
1364 {
1365 std::lock_guard lock(m_spatial_captures_mutex);
1366 auto it = m_spatial_caches.find(filepath);
1367 if (it != m_spatial_caches.end()) {
1368 cache = it->second;
1369 } else {
1370 auto new_cache = std::make_shared<IO::SpatialCache>();
1371 if (!new_cache->open(filepath)) {
1373 "capture_spatial: failed to open '{}': {}", filepath, new_cache->get_last_error());
1374 return 0;
1375 }
1376 cache = new_cache;
1377 m_spatial_caches.emplace(filepath, cache);
1378 }
1379 ++m_spatial_cache_refcounts[filepath];
1380 }
1381
1382 auto capture = std::make_unique<IO::SpatialCapture>(*m_scheduler, cache, std::move(sources));
1383 capture->start(max_frames, frame_interval);
1384
1385 const uint32_t id = m_next_spatial_capture_id.fetch_add(1, std::memory_order_relaxed);
1386
1387 std::lock_guard lock(m_spatial_captures_mutex);
1388 m_spatial_captures.emplace(id, SpatialCaptureEntry { .capture = std::move(capture), .filepath = filepath });
1389 return id;
1390}
#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
@ FileIO
Filesystem I/O operations.
@ IO
Networking, file handling, streaming.

References MayaFlux::IO::IOManager::SpatialCaptureEntry::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.