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

◆ start()

void MayaFlux::IO::SpatialCapture::start ( uint32_t max_frames = 0,
uint64_t frame_interval = 1 )

Spawn the capture routine, resetting the frame counter.

Parameters
max_framesStop after this many frames. Zero records until stop().
frame_intervalFrames between captures.

Definition at line 97 of file SpatialTransfer.cpp.

98{
99 if (!m_cache) {
101 "SpatialCapture: cannot start, null cache");
102 return;
103 }
104
105 if (m_sources.empty()) {
107 "SpatialCapture: cannot start, no sources");
108 return;
109 }
110
111 stop();
112
113 m_state = std::make_shared<CaptureState>();
114 m_state->cache = m_cache;
115 m_state->sources = m_sources;
116 m_state->max_frames = max_frames;
117 m_state->recording.store(true, std::memory_order_release);
118
119 m_task_name = "spatial_capture_"
120 + std::to_string(g_next_spatial_capture_id.fetch_add(1, std::memory_order_relaxed));
121
122 auto routine = [](Vruta::TaskScheduler&,
123 std::shared_ptr<CaptureState> state,
124 uint64_t interval) -> Vruta::GraphicsRoutine {
125 auto& p = co_await Kriya::GetGraphicsPromise {};
126 while (!p.should_terminate
127 && !state->stop_requested.load(std::memory_order_acquire)
128 && run_one_frame(*state)) {
129 co_await Kriya::FrameDelay { .frames_to_wait = interval };
130 }
131 state->recording.store(false, std::memory_order_release);
132 };
133
134 m_scheduler.add_task(
135 std::make_shared<Vruta::GraphicsRoutine>(
136 routine(m_scheduler, m_state, frame_interval)),
137 m_task_name, false);
138
140 "SpatialCapture: recording {} stream(s) every {} frame(s), {}",
141 m_sources.size(), frame_interval,
142 max_frames == 0 ? std::string("unbounded")
143 : std::format("{} frames", max_frames));
144}
#define MF_INFO(comp, ctx,...)
#define MF_ERROR(comp, ctx,...)
std::shared_ptr< SpatialCache > m_cache
std::vector< SpatialCaptureSource > m_sources
static bool run_one_frame(CaptureState &state)
One tick: write every source's stream.
std::shared_ptr< CaptureState > m_state
Vruta::TaskScheduler & m_scheduler
void stop()
Request the capture routine stop.
@ FileIO
Filesystem I/O operations.
@ IO
Networking, file handling, streaming.
GetPromiseBase< Vruta::graphics_promise > GetGraphicsPromise
Graphics domain promise accessor.

References MayaFlux::Journal::FileIO, MayaFlux::Journal::IO, m_cache, m_scheduler, m_sources, m_state, m_task_name, MF_ERROR, MF_INFO, run_one_frame(), and stop().

Referenced by operator=().

Here is the call graph for this function:
Here is the caller graph for this function: