MayaFlux 0.5.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 96 of file SpatialTransfer.cpp.

97{
98 if (!m_cache) {
100 "SpatialCapture: cannot start, null cache");
101 return;
102 }
103
104 if (m_sources.empty()) {
106 "SpatialCapture: cannot start, no sources");
107 return;
108 }
109
110 stop();
111
112 m_state = std::make_shared<CaptureState>();
113 m_state->cache = m_cache;
114 m_state->sources = m_sources;
115 m_state->max_frames = max_frames;
116 m_state->recording.store(true, std::memory_order_release);
117
118 m_task_name = "spatial_capture_"
119 + std::to_string(g_next_spatial_capture_id.fetch_add(1, std::memory_order_relaxed));
120
121 auto routine = [](Vruta::TaskScheduler&,
122 std::shared_ptr<CaptureState> state,
123 uint64_t interval) -> Vruta::GraphicsRoutine {
124 auto& p = co_await Kriya::GetGraphicsPromise {};
125 while (!p.should_terminate
126 && !state->stop_requested.load(std::memory_order_acquire)
127 && run_one_frame(*state)) {
128 co_await Kriya::FrameDelay { .frames_to_wait = interval };
129 }
130 state->recording.store(false, std::memory_order_release);
131 };
132
134 std::make_shared<Vruta::GraphicsRoutine>(
135 routine(m_scheduler, m_state, frame_interval)),
136 m_task_name, false);
137
139 "SpatialCapture: recording {} stream(s) every {} frame(s), {}",
140 m_sources.size(), frame_interval,
141 max_frames == 0 ? std::string("unbounded")
142 : std::format("{} frames", max_frames));
143}
#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.
void add_task(const std::shared_ptr< Routine > &routine, const std::string &name="", bool initialize=false)
Add a routine to the scheduler based on its processing token.
Definition Scheduler.cpp:23
@ FileIO
Filesystem I/O operations.
@ IO
Networking, file handling, streaming.
GetPromiseBase< Vruta::graphics_promise > GetGraphicsPromise
Graphics domain promise accessor.

References MayaFlux::Vruta::TaskScheduler::add_task(), MayaFlux::Journal::FileIO, MayaFlux::Kriya::FrameDelay::frames_to_wait, MayaFlux::Journal::IO, m_cache, m_scheduler, m_sources, m_state, m_task_name, MF_ERROR, MF_INFO, run_one_frame(), and stop().

+ Here is the call graph for this function: