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

◆ capture_to_stream() [2/3]

BufferOperation MayaFlux::Kriya::BufferOperation::capture_to_stream ( const std::shared_ptr< IO::IOManager > &  io_manager,
const std::shared_ptr< Kakshya::VideoStreamContainer > &  container,
uint64_t  ring_frames = 0,
std::optional< Portal::Graphics::RenderConfig >  live = std::nullopt,
std::optional< Portal::Graphics::RenderConfig >  display = std::nullopt 
)
static

Capture an opened camera or loaded video into a dynamic video stream it creates.

The container form of the camera and file forms, which open the source and call this. A container already hooked, for example by piping it into Graphics, keeps its buffer; an unhooked one is hooked here. The ring is sized from that buffer. Audio extracted with the video is not touched: pipe the container into Graphics first to hear it.

Parameters
ring_framesFrames the ring keeps; zero keeps three seconds at the registered frame rate.
liveDraws the live source when given.
displayDraws the stream through the pipeline's IOManager when given; the pipeline needs one.

Definition at line 288 of file BufferOperation.cpp.

294{
295 if (!container) {
296 error<std::runtime_error>(Journal::Component::Kriya, Journal::Context::AsyncIO,
297 std::source_location::current(), "capture_to_stream: null video container");
298 }
299
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);
303 if (!buffer) {
304 buffer = io_manager->hook_camera_to_buffer(camera);
305 }
306 } else {
307 buffer = io_manager->get_video_buffer(container);
308 if (!buffer) {
309 buffer = io_manager->hook_video_container_to_buffer(container);
310 }
311 }
312
313 if (!buffer) {
314 error<std::runtime_error>(Journal::Component::Kriya, Journal::Context::AsyncIO,
315 std::source_location::current(), "Failed to hook video container to graphics buffer");
316 }
317
318 if (live) {
320 }
321
323 op.m_source_graphics_buffer = buffer;
324 op.m_target_graphics_stream = make_ring(buffer, ring_frames);
325 op.m_render = std::move(display);
326 return op;
327}
std::shared_ptr< NetworkGeometryBuffer > buffer
BufferOperation(OpType type, BufferCapture capture)
@ ROUTE
Route data to destination (buffer or container)
@ GRAPHICS_BACKEND
Standard graphics processing backend configuration.
@ 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.

References MayaFlux::Journal::AsyncIO, buffer, MayaFlux::Kriya::detail::ensure_rendering(), MayaFlux::Buffers::GRAPHICS_BACKEND, MayaFlux::Journal::Kriya, m_render, m_source_graphics_buffer, m_target_graphics_stream, and ROUTE.

+ Here is the call graph for this function: