20 std::shared_ptr<Kakshya::DynamicVideoStream> make_ring(
21 const std::shared_ptr<Buffers::VideoContainerBuffer>& source,
26 return std::make_shared<Kakshya::DynamicVideoStream>(Kakshya::VideoStreamSpec {
27 .width =
source->get_width(),
29 .format =
source->get_format(),
31 .ring_frames = frames });
36 if (capture.get_audio_buffer()) {
39 if (capture.get_graphics_buffer()) {
42 throw std::invalid_argument(
"Capture operation requires a source buffer");
48 const std::shared_ptr<Buffers::BufferManager>& buffer_manager,
49 uint32_t input_channel,
53 auto input_buffer = std::make_shared<Buffers::AudioBuffer>(input_channel);
54 buffer_manager->register_input_listener(input_buffer, input_channel);
66 const std::shared_ptr<Buffers::BufferManager>& buffer_manager,
67 uint32_t input_channel)
69 auto input_buffer = std::make_shared<Buffers::AudioBuffer>(input_channel);
70 buffer_manager->register_input_listener(input_buffer, input_channel);
76 const std::shared_ptr<IO::IOManager>& io_manager,
80 std::optional<Portal::Graphics::RenderConfig> render)
82 auto camera = io_manager->open_camera(config);
85 std::source_location::current(),
"Failed to open camera");
88 auto buffer = io_manager->hook_camera_to_buffer(camera);
91 std::source_location::current(),
"Failed to hook camera to graphics buffer");
102 const std::shared_ptr<IO::IOManager>& io_manager,
104 std::optional<Portal::Graphics::RenderConfig> render)
106 auto camera = io_manager->open_camera(config);
109 std::source_location::current(),
"Failed to open camera");
112 auto buffer = io_manager->hook_camera_to_buffer(camera);
115 std::source_location::current(),
"Failed to hook camera to graphics buffer");
126 const std::shared_ptr<IO::IOManager>& io_manager,
127 const std::string& filepath,
129 uint32_t cycle_count)
131 auto file_container = io_manager->load_audio(filepath);
132 if (!file_container) {
134 "Failed to load audio file: {}", filepath);
137 auto file_buffer = std::make_shared<Buffers::SoundFileBridge>(channel, file_container);
150 const std::shared_ptr<IO::IOManager>& io_manager,
151 const std::string& filepath,
153 uint32_t cycle_count,
154 std::optional<Portal::Graphics::RenderConfig> render)
156 auto [video, audio] = io_manager->load_video(filepath, config);
159 std::source_location::current(),
"Failed to load video file: {}", filepath);
162 auto buffer = io_manager->hook_video_container_to_buffer(video);
165 std::source_location::current(),
"Failed to hook video file to graphics buffer: {}", filepath);
179 const std::shared_ptr<IO::IOManager>& io_manager,
180 const std::string& filepath,
183 auto file_container = io_manager->load_audio(filepath);
184 if (!file_container) {
186 "Failed to load audio file: {}", filepath);
189 auto file_buffer = std::make_shared<Buffers::SoundFileBridge>(channel, file_container);
196 const std::shared_ptr<IO::IOManager>& io_manager,
197 const std::string& filepath,
199 std::optional<Portal::Graphics::RenderConfig> render)
201 auto [video, audio] = io_manager->load_video(filepath, config);
204 std::source_location::current(),
"Failed to load video file: {}", filepath);
207 auto buffer = io_manager->hook_video_container_to_buffer(video);
210 std::source_location::current(),
"Failed to hook video file to graphics buffer: {}", filepath);
221 const std::shared_ptr<IO::IOManager>& io_manager,
222 const std::string& filepath,
223 std::shared_ptr<Kakshya::DynamicSoundStream> target_stream,
224 uint32_t cycle_count)
226 auto file_container = io_manager->load_audio(filepath);
227 if (!file_container) {
229 "Failed to load audio file: {}", filepath);
232 auto temp_buffer = std::make_shared<Buffers::SoundFileBridge>(0, file_container);
243 const std::shared_ptr<IO::IOManager>& io_manager,
244 const std::string& filepath,
245 std::shared_ptr<Kakshya::DynamicVideoStream> target_stream,
247 uint32_t cycle_count,
248 std::optional<Portal::Graphics::RenderConfig> render)
250 auto [video, audio] = io_manager->load_video(filepath, config);
253 std::source_location::current(),
"Failed to load video file: {}", filepath);
257 auto buffer = io_manager->hook_video_container_to_buffer(video);
260 std::source_location::current(),
"Failed to hook video file to graphics buffer: {}", filepath);
273 const std::shared_ptr<IO::IOManager>& io_manager,
275 uint64_t ring_frames,
276 std::optional<Portal::Graphics::RenderConfig> live,
277 std::optional<Portal::Graphics::RenderConfig> display)
279 auto camera = io_manager->open_camera(config);
282 std::source_location::current(),
"Failed to open camera");
285 return capture_to_stream(io_manager, camera, ring_frames, std::move(live), std::move(display));
289 const std::shared_ptr<IO::IOManager>& io_manager,
290 const std::shared_ptr<Kakshya::VideoStreamContainer>& container,
291 uint64_t ring_frames,
292 std::optional<Portal::Graphics::RenderConfig> live,
293 std::optional<Portal::Graphics::RenderConfig> display)
297 std::source_location::current(),
"capture_to_stream: null video container");
300 std::shared_ptr<Buffers::VideoContainerBuffer>
buffer;
301 if (
const auto camera = std::dynamic_pointer_cast<Kakshya::CameraContainer>(container)) {
302 buffer = io_manager->get_camera_buffer(camera);
304 buffer = io_manager->hook_camera_to_buffer(camera);
307 buffer = io_manager->get_video_buffer(container);
309 buffer = io_manager->hook_video_container_to_buffer(container);
315 std::source_location::current(),
"Failed to hook video container to graphics buffer");
330 const std::shared_ptr<IO::IOManager>& io_manager,
331 const std::string& filepath,
333 uint64_t ring_frames,
334 std::optional<Portal::Graphics::RenderConfig> live,
335 std::optional<Portal::Graphics::RenderConfig> display)
337 auto [video, audio] = io_manager->load_video(filepath, config);
340 std::source_location::current(),
"Failed to load video file: {}", filepath);
343 return capture_to_stream(io_manager, video, ring_frames, std::move(live), std::move(display));
369 std::shared_ptr<Buffers::TextureArrayBuffer> target, uint32_t layer)
377 std::shared_ptr<Buffers::TextureArrayBuffer> target,
378 std::vector<std::shared_ptr<Core::VKImage>> images)
394 std::shared_ptr<Kakshya::DynamicVideoStream> target,
395 std::optional<Portal::Graphics::RenderConfig> render)
404 std::shared_ptr<Buffers::AudioBuffer> target,
405 uint64_t start_frame,
417 std::shared_ptr<Kakshya::DynamicVideoStream> source,
418 std::shared_ptr<Buffers::VKBuffer> target,
419 uint64_t start_frame,
448 std::shared_ptr<Buffers::AudioBuffer> target)
458 std::vector<std::shared_ptr<Buffers::VKBuffer>> sources,
460 std::shared_ptr<Buffers::VKBuffer> target)
471 std::shared_ptr<Kakshya::DynamicSoundStream> target)
481 std::vector<std::shared_ptr<Kakshya::DynamicVideoStream>> sources,
483 std::shared_ptr<Kakshya::DynamicVideoStream> target)
493 std::shared_ptr<Buffers::AudioBuffer>
buffer,
503 std::shared_ptr<Buffers::VKBuffer>
buffer,
518 std::shared_ptr<Buffers::VKBuffer>
buffer,
519 std::optional<Portal::Graphics::RenderConfig> render)
581 , m_capture(
std::move(capture))
582 , m_token(capture_token(m_capture))
583 , m_tag(m_capture.get_tag())
std::shared_ptr< NetworkGeometryBuffer > buffer
vk::PhysicalDeviceType type
BufferCapture & for_cycles(uint32_t count)
Set the number of times to execute this capture operation.
CaptureMode
Defines the data capture and retention strategy.
@ TRANSIENT
Single cycle capture (default) - data expires after 1 cycle.
@ ACCUMULATE
Accumulate over multiple cycles in container.
Flexible data capture interface for buffer-based processing pipelines.
std::function< bool(uint32_t)> m_condition
Buffers::GraphicsProcessingFunction m_graphics_buffer_modifier
ExecutionPhase m_execution_phase
static BufferOperation route_to_container(std::shared_ptr< Kakshya::DynamicSoundStream > target, uint32_t channel=0)
Create a routing operation to DynamicSoundStream destination.
static CaptureBuilder capture_input_from(const std::shared_ptr< Buffers::BufferManager > &buffer_manager, uint32_t input_channel)
Create CaptureBuilder for input channel with fluent configuration.
BufferOperation & for_cycles(uint32_t count)
BufferOperation(OpType type, BufferCapture capture)
std::vector< std::shared_ptr< Buffers::AudioBuffer > > m_source_audio_buffers
static BufferOperation transform(TransformationFunction transformer, Buffers::ProcessingToken token=Buffers::ProcessingToken::AUDIO_BACKEND)
Create a transform operation with custom transformation function.
std::vector< std::shared_ptr< Buffers::VKBuffer > > m_source_graphics_buffers
std::shared_ptr< Kakshya::DynamicVideoStream > m_target_graphics_stream
Buffers::AudioProcessingFunction m_audio_buffer_modifier
BufferOperation & as_process_phase()
Hint that this operation should execute in process phase.
static bool is_capture_phase_operation(const BufferOperation &op)
std::shared_ptr< Buffers::VKBuffer > m_source_graphics_buffer
static BufferOperation capture_to_stream(const std::shared_ptr< IO::IOManager > &io_manager, const IO::CameraConfig &config, uint64_t ring_frames=0, std::optional< Portal::Graphics::RenderConfig > live=std::nullopt, std::optional< Portal::Graphics::RenderConfig > display=std::nullopt)
Capture a camera straight into a dynamic video stream it creates.
static BufferOperation capture(BufferCapture capture)
Create a capture operation using BufferCapture configuration.
BufferOperation & with_tag(const std::string &tag)
Assign identification tag.
static BufferOperation load_from_container(std::shared_ptr< Kakshya::DynamicSoundStream > source, std::shared_ptr< Buffers::AudioBuffer > target, uint64_t start_frame=0, uint32_t length=0)
Create a load operation from container to buffer.
BufferOperation & every_n_cycles(uint32_t n)
Set cycle interval for periodic execution.
static BufferOperation fuse_containers(std::vector< std::shared_ptr< Kakshya::DynamicSoundStream > > sources, TransformVectorFunction fusion_func, std::shared_ptr< Kakshya::DynamicSoundStream > target)
Create a fusion operation for multiple DynamicSoundStream sources.
std::shared_ptr< Buffers::AudioBuffer > m_target_audio_buffer
static CaptureBuilder capture_camera_from(const std::shared_ptr< IO::IOManager > &io_manager, const IO::CameraConfig &config, std::optional< Portal::Graphics::RenderConfig > render=std::nullopt)
Open a camera and return its capture builder.
std::shared_ptr< Kakshya::VideoStreamContainer > m_source_graphics_stream
static BufferOperation capture_file(const std::shared_ptr< IO::IOManager > &io_manager, const std::string &filepath, uint32_t channel=0, uint32_t cycle_count=0)
Create a file capture operation that reads from file and stores in stream.
static BufferOperation file_to_stream(const std::shared_ptr< IO::IOManager > &io_manager, const std::string &filepath, std::shared_ptr< Kakshya::DynamicSoundStream > target_stream, uint32_t cycle_count=0)
Create operation to route file data to DynamicSoundStream.
bool is_streaming() const
Check if this operation is a streaming operation.
static BufferOperation route_to_buffer(std::shared_ptr< Buffers::AudioBuffer > target)
Create a routing operation to AudioBuffer destination.
TransformVectorFunction m_fusion_function
static BufferOperation capture_camera(const std::shared_ptr< IO::IOManager > &io_manager, const IO::CameraConfig &config, BufferCapture::CaptureMode mode=BufferCapture::CaptureMode::TRANSIENT, uint32_t cycle_count=1, std::optional< Portal::Graphics::RenderConfig > render=std::nullopt)
Open and capture a camera through IOManager.
std::vector< std::shared_ptr< Core::VKImage > > m_source_images
BufferOperation & with_priority(uint8_t priority)
Set execution priority for scheduler ordering.
static CaptureBuilder capture_from(std::shared_ptr< Buffers::AudioBuffer > buffer)
Create a CaptureBuilder for fluent capture configuration.
BufferOperation & on_token(Buffers::ProcessingToken token)
Set processing token for execution context.
OpType get_type() const
Getters for internal state (read-only)
Buffers::ProcessingToken m_token
static BufferOperation dispatch_to(OperationFunction handler, Buffers::ProcessingToken token=Buffers::ProcessingToken::AUDIO_BACKEND)
Create a dispatch operation for external processing.
static BufferOperation capture_input(const std::shared_ptr< Buffers::BufferManager > &buffer_manager, uint32_t input_channel, BufferCapture::CaptureMode mode=BufferCapture::CaptureMode::ACCUMULATE, uint32_t cycle_count=0)
Create capture operation from input channel using convenience API.
uint32_t m_cycle_interval
static BufferOperation when(std::function< bool(uint32_t)> condition, Buffers::ProcessingToken token=Buffers::ProcessingToken::AUDIO_BACKEND)
Create a conditional operation for pipeline branching.
std::vector< std::shared_ptr< Kakshya::DynamicVideoStream > > m_source_graphics_streams
uint32_t m_modify_cycle_count
std::shared_ptr< Kakshya::DynamicSoundStream > m_source_audio_stream
static BufferOperation modify_buffer(std::shared_ptr< Buffers::AudioBuffer > buffer, Buffers::AudioProcessingFunction modifier)
Create a modify operation for direct buffer manipulation.
std::vector< std::shared_ptr< Kakshya::DynamicSoundStream > > m_source_audio_streams
TransformationFunction m_transformer
BufferOperation & as_streaming()
Mark this operation as streaming (executes continuously) Useful for modify_buffer and similar statefu...
uint32_t m_target_audio_channel
OperationFunction m_dispatch_handler
std::shared_ptr< Kakshya::DynamicSoundStream > m_target_audio_stream
OpType
Defines the fundamental operation types in the processing pipeline.
@ BRANCH
Branch to sub-pipeline based on conditions.
@ SYNC
Synchronize with timing/cycles for coordination.
@ LOAD
Load data from container to buffer with position control.
@ CONDITION
Conditional operation for branching logic.
@ FUSE
Fuse multiple sources using custom fusion functions.
@ ROUTE
Route data to destination (buffer or container)
@ CAPTURE
Capture data from source buffer using BufferCapture strategy.
@ MODIFY
Modify Buffer Data using custom quick process.
@ DISPATCH
Dispatch to external handler for custom processing.
@ TRANSFORM
Apply transformation function to data variants.
static BufferOperation fuse_data(std::vector< std::shared_ptr< Buffers::AudioBuffer > > sources, TransformVectorFunction fusion_func, std::shared_ptr< Buffers::AudioBuffer > target)
Create a fusion operation for multiple AudioBuffer sources.
std::shared_ptr< Buffers::VKBuffer > m_target_graphics_buffer
std::optional< Portal::Graphics::RenderConfig > m_render
static bool is_process_phase_operation(const BufferOperation &op)
static CaptureBuilder capture_file_from(const std::shared_ptr< IO::IOManager > &io_manager, const std::string &filepath, uint32_t channel=0)
Create CaptureBuilder for file with fluent configuration.
ExecutionPhase get_execution_phase() const
Get the execution phase hint for this operation.
Fundamental unit of operation in buffer processing pipelines.
CaptureBuilder & on_capture_processing()
Set processing control to ON_CAPTURE mode.
Fluent builder interface for constructing BufferCapture configurations.
std::function< void(const std::shared_ptr< AudioBuffer > &)> AudioProcessingFunction
Audio processing function - receives correctly-typed AudioBuffer.
ProcessingToken
Bitfield enum defining processing characteristics and backend requirements for buffer operations.
@ AUDIO_BACKEND
Standard audio processing backend configuration.
@ GRAPHICS_BACKEND
Standard graphics processing backend configuration.
std::function< void(const std::shared_ptr< VKBuffer > &)> GraphicsProcessingFunction
Graphics processing function - receives correctly-typed VKBuffer.
@ AsyncIO
Async I/O operations ( network, streaming)
@ Kriya
Automatable tasks and fluent scheduling api for Nodes and Buffers.
bool ensure_rendering(const std::shared_ptr< Buffers::VKBuffer > &buffer, const Portal::Graphics::RenderConfig &config)
Make a buffer draw to the window in a render config, unless it already does.
std::function< Kakshya::DataVariant(std::vector< Kakshya::DataVariant > &, uint32_t)> TransformVectorFunction
std::function< Kakshya::DataVariant(Kakshya::DataVariant &, uint32_t)> TransformationFunction
std::function< void(Kakshya::DataVariant &, uint32_t)> OperationFunction
MAYAFLUX_API uint32_t s_registered_frame_rate
Configuration for opening a camera device via FFmpeg.